Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@ class AlertsAndActionSheetsTests: XCTestCase {
environment: AlertAndSheetEnvironment()
)

store.assert(
.send(.alertButtonTapped) {
$0.alert = .init(
title: .init("Alert!"),
message: .init("This is an alert"),
primaryButton: .cancel(),
secondaryButton: .default(.init("Increment"), send: .incrementButtonTapped)
)
},
.send(.incrementButtonTapped) {
$0.alert = .init(title: .init("Incremented!"))
$0.count = 1
},
.send(.alertDismissed) {
$0.alert = nil
}
)
store.send(.alertButtonTapped) {
$0.alert = .init(
title: .init("Alert!"),
message: .init("This is an alert"),
primaryButton: .cancel(),
secondaryButton: .default(.init("Increment"), send: .incrementButtonTapped)
)
}
store.send(.incrementButtonTapped) {
$0.alert = .init(title: .init("Incremented!"))
$0.count = 1
}
store.send(.alertDismissed) {
$0.alert = nil
}
}

func testActionSheet() {
Expand All @@ -39,25 +37,23 @@ class AlertsAndActionSheetsTests: XCTestCase {
environment: AlertAndSheetEnvironment()
)

store.assert(
.send(.actionSheetButtonTapped) {
$0.actionSheet = .init(
title: .init("Action sheet"),
message: .init("This is an action sheet."),
buttons: [
.cancel(),
.default(.init("Increment"), send: .incrementButtonTapped),
.default(.init("Decrement"), send: .decrementButtonTapped),
]
)
},
.send(.incrementButtonTapped) {
$0.alert = .init(title: .init("Incremented!"))
$0.count = 1
},
.send(.actionSheetDismissed) {
$0.actionSheet = nil
}
)
store.send(.actionSheetButtonTapped) {
$0.actionSheet = .init(
title: .init("Action sheet"),
message: .init("This is an action sheet."),
buttons: [
.cancel(),
.default(.init("Increment"), send: .incrementButtonTapped),
.default(.init("Decrement"), send: .decrementButtonTapped),
]
)
}
store.send(.incrementButtonTapped) {
$0.alert = .init(title: .init("Incremented!"))
$0.count = 1
}
store.send(.actionSheetDismissed) {
$0.actionSheet = nil
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,47 @@ class AnimationTests: XCTestCase {
)
)

store.assert(
.send(.rainbowButtonTapped),

.receive(.setColor(.red)) {
$0.circleColor = .red
},

.do { self.scheduler.advance(by: .seconds(1)) },
.receive(.setColor(.blue)) {
$0.circleColor = .blue
},

.do { self.scheduler.advance(by: .seconds(1)) },
.receive(.setColor(.green)) {
$0.circleColor = .green
},

.do { self.scheduler.advance(by: .seconds(1)) },
.receive(.setColor(.orange)) {
$0.circleColor = .orange
},

.do { self.scheduler.advance(by: .seconds(1)) },
.receive(.setColor(.pink)) {
$0.circleColor = .pink
},

.do { self.scheduler.advance(by: .seconds(1)) },
.receive(.setColor(.purple)) {
$0.circleColor = .purple
},

.do { self.scheduler.advance(by: .seconds(1)) },
.receive(.setColor(.yellow)) {
$0.circleColor = .yellow
},

.do { self.scheduler.advance(by: .seconds(1)) },
.receive(.setColor(.white)) {
$0.circleColor = .white
},

.do { self.scheduler.run() }
)
store.send(.rainbowButtonTapped)

store.receive(.setColor(.red)) {
$0.circleColor = .red
}

self.scheduler.advance(by: .seconds(1))
store.receive(.setColor(.blue)) {
$0.circleColor = .blue
}

self.scheduler.advance(by: .seconds(1))
store.receive(.setColor(.green)) {
$0.circleColor = .green
}

self.scheduler.advance(by: .seconds(1))
store.receive(.setColor(.orange)) {
$0.circleColor = .orange
}

self.scheduler.advance(by: .seconds(1))
store.receive(.setColor(.pink)) {
$0.circleColor = .pink
}

self.scheduler.advance(by: .seconds(1))
store.receive(.setColor(.purple)) {
$0.circleColor = .purple
}

self.scheduler.advance(by: .seconds(1))
store.receive(.setColor(.yellow)) {
$0.circleColor = .yellow
}

self.scheduler.advance(by: .seconds(1))
store.receive(.setColor(.white)) {
$0.circleColor = .white
}

self.scheduler.run()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,21 @@ class BindingFormTests: XCTestCase {
environment: BindingFormEnvironment()
)

store.assert(
.send(.binding(.set(\.sliderValue, 2))) {
$0.sliderValue = 2
},
.send(.binding(.set(\.stepCount, 1))) {
$0.sliderValue = 1
$0.stepCount = 1
},
.send(.binding(.set(\.text, "Blob"))) {
$0.text = "Blob"
},
.send(.binding(.set(\.toggleIsOn, true))) {
$0.toggleIsOn = true
},
.send(.resetButtonTapped) {
$0 = .init(sliderValue: 5, stepCount: 10, text: "", toggleIsOn: false)
}
)
store.send(.binding(.set(\.sliderValue, 2))) {
$0.sliderValue = 2
}
store.send(.binding(.set(\.stepCount, 1))) {
$0.sliderValue = 1
$0.stepCount = 1
}
store.send(.binding(.set(\.text, "Blob"))) {
$0.text = "Blob"
}
store.send(.binding(.set(\.toggleIsOn, true))) {
$0.toggleIsOn = true
}
store.send(.resetButtonTapped) {
$0 = .init(sliderValue: 5, stepCount: 10, text: "", toggleIsOn: false)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ class SharedStateTests: XCTestCase {
environment: ()
)

store.assert(
.send(.selectTab(.profile)) {
$0.currentTab = .profile
$0.profile = .init(
currentTab: .profile, count: 0, maxCount: 0, minCount: 0, numberOfCounts: 0)
},
.send(.profile(.resetCounterButtonTapped)) {
$0.currentTab = .counter
$0.profile = .init(
currentTab: .counter, count: 0, maxCount: 0, minCount: 0, numberOfCounts: 0)
})
store.send(.selectTab(.profile)) {
$0.currentTab = .profile
$0.profile = .init(
currentTab: .profile, count: 0, maxCount: 0, minCount: 0, numberOfCounts: 0)
}
store.send(.profile(.resetCounterButtonTapped)) {
$0.currentTab = .counter
$0.profile = .init(
currentTab: .counter, count: 0, maxCount: 0, minCount: 0, numberOfCounts: 0)
}
}

func testTabSelection() {
Expand All @@ -32,17 +31,16 @@ class SharedStateTests: XCTestCase {
environment: ()
)

store.assert(
.send(.selectTab(.profile)) {
$0.currentTab = .profile
$0.profile = .init(
currentTab: .profile, count: 0, maxCount: 0, minCount: 0, numberOfCounts: 0)
},
.send(.selectTab(.counter)) {
$0.currentTab = .counter
$0.profile = .init(
currentTab: .counter, count: 0, maxCount: 0, minCount: 0, numberOfCounts: 0)
})
store.send(.selectTab(.profile)) {
$0.currentTab = .profile
$0.profile = .init(
currentTab: .profile, count: 0, maxCount: 0, minCount: 0, numberOfCounts: 0)
}
store.send(.selectTab(.counter)) {
$0.currentTab = .counter
$0.profile = .init(
currentTab: .counter, count: 0, maxCount: 0, minCount: 0, numberOfCounts: 0)
}
}

func testSharedCounts() {
Expand All @@ -52,21 +50,20 @@ class SharedStateTests: XCTestCase {
environment: ()
)

store.assert(
.send(.counter(.incrementButtonTapped)) {
$0.counter.count = 1
$0.counter.maxCount = 1
$0.counter.numberOfCounts = 1
},
.send(.counter(.decrementButtonTapped)) {
$0.counter.count = 0
$0.counter.numberOfCounts = 2
},
.send(.counter(.decrementButtonTapped)) {
$0.counter.count = -1
$0.counter.minCount = -1
$0.counter.numberOfCounts = 3
})
store.send(.counter(.incrementButtonTapped)) {
$0.counter.count = 1
$0.counter.maxCount = 1
$0.counter.numberOfCounts = 1
}
store.send(.counter(.decrementButtonTapped)) {
$0.counter.count = 0
$0.counter.numberOfCounts = 2
}
store.send(.counter(.decrementButtonTapped)) {
$0.counter.count = -1
$0.counter.minCount = -1
$0.counter.numberOfCounts = 3
}
}

func testIsPrimeWhenPrime() {
Expand All @@ -77,16 +74,14 @@ class SharedStateTests: XCTestCase {
environment: ()
)

store.assert(
.send(.isPrimeButtonTapped) {
$0.alert = .init(
title: .init("👍 The number \($0.count) is prime!")
)
},
.send(.alertDismissed) {
$0.alert = nil
}
)
store.send(.isPrimeButtonTapped) {
$0.alert = .init(
title: .init("👍 The number \($0.count) is prime!")
)
}
store.send(.alertDismissed) {
$0.alert = nil
}
}

func testIsPrimeWhenNotPrime() {
Expand All @@ -97,15 +92,13 @@ class SharedStateTests: XCTestCase {
environment: ()
)

store.assert(
.send(.isPrimeButtonTapped) {
$0.alert = .init(
title: .init("👎 The number \($0.count) is not prime :(")
)
},
.send(.alertDismissed) {
$0.alert = nil
}
)
store.send(.isPrimeButtonTapped) {
$0.alert = .init(
title: .init("👎 The number \($0.count) is not prime :(")
)
}
store.send(.alertDismissed) {
$0.alert = nil
}
}
}
Loading