-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
DashboardDataSourceTests.swift
41 lines (30 loc) · 1.69 KB
/
DashboardDataSourceTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@testable import Kickstarter_Framework
@testable import KsApi
@testable import Library
import Prelude
import XCTest
internal final class DashboardDataSourceTests: XCTestCase {
let dataSource = DashboardDataSource()
let tableView = UITableView()
func testDataSource() {
let project = Project.template
XCTAssertEqual(0, self.dataSource.numberOfSections(in: self.tableView))
self.dataSource.load(project: project)
XCTAssertEqual(2, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(1, self.dataSource.tableView(self.tableView, numberOfRowsInSection: 0))
XCTAssertEqual(1, self.dataSource.tableView(self.tableView, numberOfRowsInSection: 1))
XCTAssertEqual("DashboardContextCell", self.dataSource.reusableId(item: 0, section: 0))
XCTAssertEqual("DashboardActionCell", self.dataSource.reusableId(item: 0, section: 1))
XCTAssertEqual(project, self.dataSource[itemSection: (0, 0)] as? Project)
let rewardStats = [ProjectStatsEnvelope.RewardStats.template]
self.dataSource.load(rewardStats: rewardStats, project: project)
XCTAssertEqual(4, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(1, self.dataSource.tableView(self.tableView, numberOfRowsInSection: 3))
XCTAssertEqual("DashboardRewardsCell", self.dataSource.reusableId(item: 0, section: 3))
let videoStats = ProjectStatsEnvelope.VideoStats.template
self.dataSource.load(videoStats: videoStats)
XCTAssertEqual(6, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(1, self.dataSource.tableView(self.tableView, numberOfRowsInSection: 5))
XCTAssertEqual("DashboardVideoCell", self.dataSource.reusableId(item: 0, section: 5))
}
}