-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
ProjectPamphletContentDataSourceTests.swift
50 lines (39 loc) · 1.57 KB
/
ProjectPamphletContentDataSourceTests.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
@testable import Kickstarter_Framework
@testable import KsApi
@testable import Library
import Prelude
import XCTest
final class ProjectPamphletContentDataSourceTests: TestCase {
let dataSource = ProjectPamphletContentDataSource()
let tableView = UITableView()
func testViewProgressSectionRows_UserIsCreatorOfProject() {
let viewProgressSection = ProjectPamphletContentDataSource.Section.creatorHeader.rawValue
let user = User.template
let project = Project.template
|> Project.lens.creator .~ user
withEnvironment(currentUser: user) {
self.dataSource.load(data: (project, .discovery))
XCTAssertEqual(1, self.dataSource.tableView(self.tableView, numberOfRowsInSection: viewProgressSection))
}
}
func testViewProgressSectionRows_UserIsNotCreatorOfProject() {
let viewProgressSection = ProjectPamphletContentDataSource.Section.creatorHeader.rawValue
let user = User.template
|> \.id .~ 123
let project = Project.template
withEnvironment(currentUser: user) {
self.dataSource.load(data: (project, .discovery))
XCTAssertEqual(0, self.dataSource.tableView(self.tableView, numberOfRowsInSection: viewProgressSection))
}
}
private func assertSectionIsShown(_ config: Config) {
let releaseBundle = MockBundle(
bundleIdentifier: KickstarterBundleIdentifier.release.rawValue,
lang: "en"
)
withEnvironment(config: config, mainBundle: releaseBundle) {
self.dataSource.load(data: (.template, .discovery))
XCTAssertEqual(8, self.dataSource.numberOfSections(in: self.tableView))
}
}
}