Skip to content

Commit 21c8b4d

Browse files
authored
Update tests to use XCTAssertNoDifference (#739)
1 parent d4b438a commit 21c8b4d

13 files changed

+205
-205
lines changed

Examples/VoiceMemos/VoiceMemosTests/VoiceMemosTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class VoiceMemosTests: XCTestCase {
269269

270270
store.send(.voiceMemo(id: url, action: .delete)) {
271271
$0.voiceMemos = []
272-
XCTAssertEqual(didStopAudioPlayerClient, true)
272+
XCTAssertNoDifference(didStopAudioPlayerClient, true)
273273
}
274274
}
275275

Tests/ComposableArchitectureTests/ComposableArchitectureTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ final class ComposableArchitectureTests: XCTestCase {
7272
testScheduler.schedule(after: testScheduler.now, interval: 2) { values.append(42) }
7373
.store(in: &self.cancellables)
7474

75-
XCTAssertEqual(values, [])
75+
XCTAssertNoDifference(values, [])
7676
testScheduler.advance()
77-
XCTAssertEqual(values, [1, 42])
77+
XCTAssertNoDifference(values, [1, 42])
7878
testScheduler.advance(by: 2)
79-
XCTAssertEqual(values, [1, 42, 1, 1, 42])
79+
XCTAssertNoDifference(values, [1, 42, 1, 1, 42])
8080
}
8181

8282
func testLongLivingEffects() {

Tests/ComposableArchitectureTests/DebugTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ final class DebugTests: XCTestCase {
88
func testTextState() {
99
var dump = ""
1010
customDump(TextState("Hello, world!"), to: &dump)
11-
XCTAssertEqual(
11+
XCTAssertNoDifference(
1212
dump,
1313
"""
1414
"Hello, world!"
@@ -22,7 +22,7 @@ final class DebugTests: XCTestCase {
2222
+ TextState("!"),
2323
to: &dump
2424
)
25-
XCTAssertEqual(
25+
XCTAssertNoDifference(
2626
dump,
2727
"""
2828
"Hello, _**world**_!"
@@ -49,7 +49,7 @@ final class DebugTests: XCTestCase {
4949
+ TextState("\n") + TextState("Not underlined purple").underline(false, color: .pink),
5050
to: &dump
5151
)
52-
XCTAssertEqual(
52+
XCTAssertNoDifference(
5353
dump,
5454
#"""
5555
"""
@@ -90,22 +90,22 @@ final class DebugTests: XCTestCase {
9090
}
9191
}
9292

93-
XCTAssertEqual(
93+
XCTAssertNoDifference(
9494
debugCaseOutput(Action.action1(true, label: "Blob")),
9595
"Action.action1(_:, label:)"
9696
)
9797

98-
XCTAssertEqual(
98+
XCTAssertNoDifference(
9999
debugCaseOutput(Action.action2(true, 1, "Blob")),
100100
"Action.action2(_:, _:, _:)"
101101
)
102102

103-
XCTAssertEqual(
103+
XCTAssertNoDifference(
104104
debugCaseOutput(Action.screenA(.row(index: 1, action: .tapped))),
105105
"Action.screenA(.row(index:, action: .tapped))"
106106
)
107107

108-
XCTAssertEqual(
108+
XCTAssertNoDifference(
109109
debugCaseOutput(Action.screenA(.row(index: 1, action: .textChanged(query: "Hi")))),
110110
"Action.screenA(.row(index:, action: .textChanged(query:)))"
111111
)

Tests/ComposableArchitectureTests/EffectCancellationTests.swift

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ final class EffectCancellationTests: XCTestCase {
2323
.sink { values.append($0) }
2424
.store(in: &self.cancellables)
2525

26-
XCTAssertEqual(values, [])
26+
XCTAssertNoDifference(values, [])
2727
subject.send(1)
28-
XCTAssertEqual(values, [1])
28+
XCTAssertNoDifference(values, [1])
2929
subject.send(2)
30-
XCTAssertEqual(values, [1, 2])
30+
XCTAssertNoDifference(values, [1, 2])
3131

3232
Effect<Never, Never>.cancel(id: CancelToken())
3333
.sink { _ in }
3434
.store(in: &self.cancellables)
3535

3636
subject.send(3)
37-
XCTAssertEqual(values, [1, 2])
37+
XCTAssertNoDifference(values, [1, 2])
3838
}
3939

4040
func testCancelInFlight() {
@@ -46,21 +46,21 @@ final class EffectCancellationTests: XCTestCase {
4646
.sink { values.append($0) }
4747
.store(in: &self.cancellables)
4848

49-
XCTAssertEqual(values, [])
49+
XCTAssertNoDifference(values, [])
5050
subject.send(1)
51-
XCTAssertEqual(values, [1])
51+
XCTAssertNoDifference(values, [1])
5252
subject.send(2)
53-
XCTAssertEqual(values, [1, 2])
53+
XCTAssertNoDifference(values, [1, 2])
5454

5555
Effect(subject)
5656
.cancellable(id: CancelToken(), cancelInFlight: true)
5757
.sink { values.append($0) }
5858
.store(in: &self.cancellables)
5959

6060
subject.send(3)
61-
XCTAssertEqual(values, [1, 2, 3])
61+
XCTAssertNoDifference(values, [1, 2, 3])
6262
subject.send(4)
63-
XCTAssertEqual(values, [1, 2, 3, 4])
63+
XCTAssertNoDifference(values, [1, 2, 3, 4])
6464
}
6565

6666
func testCancellationAfterDelay() {
@@ -73,7 +73,7 @@ final class EffectCancellationTests: XCTestCase {
7373
.sink { value = $0 }
7474
.store(in: &self.cancellables)
7575

76-
XCTAssertEqual(value, nil)
76+
XCTAssertNoDifference(value, nil)
7777

7878
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
7979
Effect<Never, Never>.cancel(id: CancelToken())
@@ -83,7 +83,7 @@ final class EffectCancellationTests: XCTestCase {
8383

8484
_ = XCTWaiter.wait(for: [self.expectation(description: "")], timeout: 0.3)
8585

86-
XCTAssertEqual(value, nil)
86+
XCTAssertNoDifference(value, nil)
8787
}
8888

8989
func testCancellationAfterDelay_WithTestScheduler() {
@@ -97,7 +97,7 @@ final class EffectCancellationTests: XCTestCase {
9797
.sink { value = $0 }
9898
.store(in: &self.cancellables)
9999

100-
XCTAssertEqual(value, nil)
100+
XCTAssertNoDifference(value, nil)
101101

102102
scheduler.advance(by: 1)
103103
Effect<Never, Never>.cancel(id: CancelToken())
@@ -106,7 +106,7 @@ final class EffectCancellationTests: XCTestCase {
106106

107107
scheduler.run()
108108

109-
XCTAssertEqual(value, nil)
109+
XCTAssertNoDifference(value, nil)
110110
}
111111

112112
func testCancellablesCleanUp_OnComplete() {
@@ -116,7 +116,7 @@ final class EffectCancellationTests: XCTestCase {
116116
.sink(receiveValue: { _ in })
117117
.store(in: &self.cancellables)
118118

119-
XCTAssertEqual([:], cancellationCancellables)
119+
XCTAssertNoDifference([:], cancellationCancellables)
120120
}
121121

122122
func testCancellablesCleanUp_OnCancel() {
@@ -132,7 +132,7 @@ final class EffectCancellationTests: XCTestCase {
132132
.sink(receiveValue: { _ in })
133133
.store(in: &self.cancellables)
134134

135-
XCTAssertEqual([:], cancellationCancellables)
135+
XCTAssertNoDifference([:], cancellationCancellables)
136136
}
137137

138138
func testDoubleCancellation() {
@@ -147,16 +147,16 @@ final class EffectCancellationTests: XCTestCase {
147147
.sink { values.append($0) }
148148
.store(in: &self.cancellables)
149149

150-
XCTAssertEqual(values, [])
150+
XCTAssertNoDifference(values, [])
151151
subject.send(1)
152-
XCTAssertEqual(values, [1])
152+
XCTAssertNoDifference(values, [1])
153153

154154
Effect<Never, Never>.cancel(id: CancelToken())
155155
.sink { _ in }
156156
.store(in: &self.cancellables)
157157

158158
subject.send(2)
159-
XCTAssertEqual(values, [1])
159+
XCTAssertNoDifference(values, [1])
160160
}
161161

162162
func testCompleteBeforeCancellation() {
@@ -171,16 +171,16 @@ final class EffectCancellationTests: XCTestCase {
171171
.store(in: &self.cancellables)
172172

173173
subject.send(1)
174-
XCTAssertEqual(values, [1])
174+
XCTAssertNoDifference(values, [1])
175175

176176
subject.send(completion: .finished)
177-
XCTAssertEqual(values, [1])
177+
XCTAssertNoDifference(values, [1])
178178

179179
Effect<Never, Never>.cancel(id: CancelToken())
180180
.sink { _ in }
181181
.store(in: &self.cancellables)
182182

183-
XCTAssertEqual(values, [1])
183+
XCTAssertNoDifference(values, [1])
184184
}
185185

186186
func testConcurrentCancels() {
@@ -240,7 +240,7 @@ final class EffectCancellationTests: XCTestCase {
240240

241241
cancellables.removeAll()
242242

243-
XCTAssertEqual([:], cancellationCancellables)
243+
XCTAssertNoDifference([:], cancellationCancellables)
244244
}
245245

246246
func testSharedId() {
@@ -264,11 +264,11 @@ final class EffectCancellationTests: XCTestCase {
264264
.sink { expectedOutput.append($0) }
265265
.store(in: &cancellables)
266266

267-
XCTAssertEqual(expectedOutput, [])
267+
XCTAssertNoDifference(expectedOutput, [])
268268
scheduler.advance(by: 1)
269-
XCTAssertEqual(expectedOutput, [1])
269+
XCTAssertNoDifference(expectedOutput, [1])
270270
scheduler.advance(by: 1)
271-
XCTAssertEqual(expectedOutput, [1, 2])
271+
XCTAssertNoDifference(expectedOutput, [1, 2])
272272
}
273273

274274
func testImmediateCancellation() {
@@ -282,8 +282,8 @@ final class EffectCancellationTests: XCTestCase {
282282
.cancellable(id: "id")
283283
.sink { expectedOutput.append($0) }
284284

285-
XCTAssertEqual(expectedOutput, [])
285+
XCTAssertNoDifference(expectedOutput, [])
286286
scheduler.advance(by: 1)
287-
XCTAssertEqual(expectedOutput, [])
287+
XCTAssertNoDifference(expectedOutput, [])
288288
}
289289
}

Tests/ComposableArchitectureTests/EffectDebounceTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@ final class EffectDebounceTests: XCTestCase {
2121
runDebouncedEffect(value: 1)
2222

2323
// Nothing emits right away.
24-
XCTAssertEqual(values, [])
24+
XCTAssertNoDifference(values, [])
2525

2626
// Waiting half the time also emits nothing
2727
scheduler.advance(by: 0.5)
28-
XCTAssertEqual(values, [])
28+
XCTAssertNoDifference(values, [])
2929

3030
// Run another debounced effect.
3131
runDebouncedEffect(value: 2)
3232

3333
// Waiting half the time emits nothing because the first debounced effect has been canceled.
3434
scheduler.advance(by: 0.5)
35-
XCTAssertEqual(values, [])
35+
XCTAssertNoDifference(values, [])
3636

3737
// Run another debounced effect.
3838
runDebouncedEffect(value: 3)
3939

4040
// Waiting half the time emits nothing because the second debounced effect has been canceled.
4141
scheduler.advance(by: 0.5)
42-
XCTAssertEqual(values, [])
42+
XCTAssertNoDifference(values, [])
4343

4444
// Waiting the rest of the time emits the final effect value.
4545
scheduler.advance(by: 0.5)
46-
XCTAssertEqual(values, [3])
46+
XCTAssertNoDifference(values, [3])
4747

4848
// Running out the scheduler
4949
scheduler.run()
50-
XCTAssertEqual(values, [3])
50+
XCTAssertNoDifference(values, [3])
5151
}
5252

5353
func testDebounceIsLazy() {
@@ -70,17 +70,17 @@ final class EffectDebounceTests: XCTestCase {
7070

7171
runDebouncedEffect(value: 1)
7272

73-
XCTAssertEqual(values, [])
74-
XCTAssertEqual(effectRuns, 0)
73+
XCTAssertNoDifference(values, [])
74+
XCTAssertNoDifference(effectRuns, 0)
7575

7676
scheduler.advance(by: 0.5)
7777

78-
XCTAssertEqual(values, [])
79-
XCTAssertEqual(effectRuns, 0)
78+
XCTAssertNoDifference(values, [])
79+
XCTAssertNoDifference(effectRuns, 0)
8080

8181
scheduler.advance(by: 0.5)
8282

83-
XCTAssertEqual(values, [1])
84-
XCTAssertEqual(effectRuns, 1)
83+
XCTAssertNoDifference(values, [1])
84+
XCTAssertNoDifference(effectRuns, 1)
8585
}
8686
}

Tests/ComposableArchitectureTests/EffectDeferredTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,33 @@ final class EffectDeferredTests: XCTestCase {
2020
runDeferredEffect(value: 1)
2121

2222
// Nothing emits right away.
23-
XCTAssertEqual(values, [])
23+
XCTAssertNoDifference(values, [])
2424

2525
// Waiting half the time also emits nothing
2626
scheduler.advance(by: 0.5)
27-
XCTAssertEqual(values, [])
27+
XCTAssertNoDifference(values, [])
2828

2929
// Run another deferred effect.
3030
runDeferredEffect(value: 2)
3131

3232
// Waiting half the time emits first deferred effect received.
3333
scheduler.advance(by: 0.5)
34-
XCTAssertEqual(values, [1])
34+
XCTAssertNoDifference(values, [1])
3535

3636
// Run another deferred effect.
3737
runDeferredEffect(value: 3)
3838

3939
// Waiting half the time emits second deferred effect received.
4040
scheduler.advance(by: 0.5)
41-
XCTAssertEqual(values, [1, 2])
41+
XCTAssertNoDifference(values, [1, 2])
4242

4343
// Waiting the rest of the time emits the final effect value.
4444
scheduler.advance(by: 0.5)
45-
XCTAssertEqual(values, [1, 2, 3])
45+
XCTAssertNoDifference(values, [1, 2, 3])
4646

4747
// Running out the scheduler
4848
scheduler.run()
49-
XCTAssertEqual(values, [1, 2, 3])
49+
XCTAssertNoDifference(values, [1, 2, 3])
5050
}
5151

5252
func testDeferredIsLazy() {
@@ -67,17 +67,17 @@ final class EffectDeferredTests: XCTestCase {
6767

6868
runDeferredEffect(value: 1)
6969

70-
XCTAssertEqual(values, [])
71-
XCTAssertEqual(effectRuns, 0)
70+
XCTAssertNoDifference(values, [])
71+
XCTAssertNoDifference(effectRuns, 0)
7272

7373
scheduler.advance(by: 0.5)
7474

75-
XCTAssertEqual(values, [])
76-
XCTAssertEqual(effectRuns, 0)
75+
XCTAssertNoDifference(values, [])
76+
XCTAssertNoDifference(effectRuns, 0)
7777

7878
scheduler.advance(by: 0.5)
7979

80-
XCTAssertEqual(values, [1])
81-
XCTAssertEqual(effectRuns, 1)
80+
XCTAssertNoDifference(values, [1])
81+
XCTAssertNoDifference(effectRuns, 1)
8282
}
8383
}

0 commit comments

Comments
 (0)