-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
DiscoveryProjectsDataSourceTest.swift
79 lines (55 loc) · 2.93 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@testable import Kickstarter_Framework
@testable import KsApi
@testable import Library
import Prelude
import XCTest
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: self.tableView))
XCTAssertEqual(1, self.dataSource.tableView(self.tableView, numberOfRowsInSection: section))
self.dataSource.show(onboarding: false)
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(0, self.dataSource.tableView(self.tableView, numberOfRowsInSection: section))
}
func testPersonalization() {
let section = DiscoveryProjectsDataSource.Section.personalization.rawValue
self.dataSource.showPersonalization(true)
XCTAssertEqual(2, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(1, self.dataSource.tableView(self.tableView, numberOfRowsInSection: section))
self.dataSource.showPersonalization(false)
XCTAssertEqual(2, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(0, self.dataSource.tableView(self.tableView, numberOfRowsInSection: section))
}
func testActivitySample() {
let section = DiscoveryProjectsDataSource.Section.activitySample.rawValue
self.dataSource.load(activities: [.template])
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(1, self.dataSource.tableView(self.tableView, numberOfRowsInSection: section))
self.dataSource.load(activities: [])
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(0, self.dataSource.tableView(self.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: self.tableView))
XCTAssertEqual(3, self.dataSource.tableView(self.tableView, numberOfRowsInSection: section))
self.dataSource.load(projects: [])
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(0, self.dataSource.tableView(self.tableView, numberOfRowsInSection: section))
}
func testProjects_ExperimentVariant() {
let section = DiscoveryProjectsDataSource.Section.projects.rawValue
self.dataSource.load(
projects: [.template, .template, .template],
params: DiscoveryParams.defaults,
projectCardVariant: .variant1
)
XCTAssertEqual(section + 1, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(3, self.dataSource.tableView(self.tableView, numberOfRowsInSection: section))
}
}