-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathDiscoveryProjectsDataSourceTest.swift
52 lines (36 loc) · 1.87 KB
/
DiscoveryProjectsDataSourceTest.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
42
43
44
45
46
47
48
49
50
51
52
import XCTest
@testable import Kickstarter_Framework
@testable import Library
@testable import KsApi
import Prelude
final class DiscoveryProjectsDataSourceTests: XCTestCase {
let dataSource = DiscoveryProjectsDataSource()
let tableView = UITableView()
func testOnboarding() {
let section = DiscoveryProjectsDataSource.Section.onboarding.rawValue
self.dataSource.show(onboarding: true)
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: tableView))
XCTAssertEqual(1, self.dataSource.tableView(tableView, numberOfRowsInSection: section))
self.dataSource.show(onboarding: false)
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: tableView))
XCTAssertEqual(0, self.dataSource.tableView(tableView, numberOfRowsInSection: section))
}
func testActivitySample() {
let section = DiscoveryProjectsDataSource.Section.activitySample.rawValue
self.dataSource.load(activities: [.template])
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: tableView))
XCTAssertEqual(1, self.dataSource.tableView(tableView, numberOfRowsInSection: section))
self.dataSource.load(activities: [])
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: tableView))
XCTAssertEqual(0, self.dataSource.tableView(tableView, numberOfRowsInSection: section))
}
func testProjects() {
let section = DiscoveryProjectsDataSource.Section.projects.rawValue
self.dataSource.load(projects: [.template, .template, .template])
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: tableView))
XCTAssertEqual(3, self.dataSource.tableView(tableView, numberOfRowsInSection: section))
self.dataSource.load(projects: [])
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: tableView))
XCTAssertEqual(0, self.dataSource.tableView(tableView, numberOfRowsInSection: section))
}
}