-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
FindFriendsViewControllerTests.swift
73 lines (58 loc) · 2.58 KB
/
FindFriendsViewControllerTests.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
import Prelude
@testable import Kickstarter_Framework
@testable import KsApi
@testable import Library
internal final class FindFriendsViewControllerTests: TestCase {
override func setUp() {
super.setUp()
AppEnvironment.pushEnvironment(mainBundle: Bundle.framework)
UIView.setAnimationsEnabled(false)
}
override func tearDown() {
AppEnvironment.popEnvironment()
UIView.setAnimationsEnabled(true)
super.tearDown()
}
func testView_ShowFacebookConnect() {
combos(Language.allLanguages, [Device.phone4_7inch]).forEach { language, device in
withEnvironment(language: language) {
let controller = FindFriendsViewController.configuredWith(source: FriendsSource.settings)
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)
FBSnapshotVerifyView(parent.view, identifier: "lang_\(language)_device_\(device)")
}
}
}
func testView_ShowFriends() {
let currentUser = .template
|> User.lens.facebookConnected .~ true
let friendNoAvatar = .template
|> User.lens.avatar.medium .~ ""
let friend1 = friendNoAvatar
|> User.lens.name .~ "Ron Swanson"
|> User.lens.location .~
(.template |> Location.lens.displayableName .~ "Pawnee, IN")
|> User.lens.stats.backedProjectsCount .~ 42
|> User.lens.stats.createdProjectsCount .~ 0
|> User.lens.isFriend .~ true
let friend2 = friendNoAvatar
|> User.lens.name .~ "David Byrne"
|> User.lens.location .~
(.template |> Location.lens.displayableName .~ "New York, NY")
|> User.lens.stats.backedProjectsCount .~ 365
|> User.lens.stats.createdProjectsCount .~ 5
let friendsResponse = .template
|> FindFriendsEnvelope.lens.users .~ [friend1, friend2, friend2, friend1, friendNoAvatar]
let friendStats = .template
|> FriendStatsEnvelope.lens.stats.friendProjectsCount .~ 1_738
|> FriendStatsEnvelope.lens.stats.remoteFriendsCount .~ 5
combos(Language.allLanguages, [Device.phone4inch, Device.phone4_7inch]).forEach { language, device in
withEnvironment(apiService: MockService(fetchFriendsResponse: friendsResponse,
fetchFriendStatsResponse: friendStats), currentUser: currentUser, language: language) {
let controller = FindFriendsViewController.configuredWith(source: FriendsSource.settings)
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)
self.scheduler.run()
FBSnapshotVerifyView(parent.view, identifier: "lang_\(language)_device_\(device)")
}
}
}
}