Skip to content

Commit fb38395

Browse files
committed
scheduler -> mainQueue
1 parent c5d96f0 commit fb38395

24 files changed

+221
-221
lines changed

Examples/CaseStudies/SwiftUICaseStudiesTests/01-GettingStarted-AnimationsTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import XCTest
55
@testable import SwiftUICaseStudies
66

77
class AnimationTests: XCTestCase {
8-
let scheduler = TestScheduler()
8+
let mainQueue = TestScheduler()
99

1010
func testRainbow() {
1111
let store = TestStore(
1212
initialState: AnimationsState(),
1313
reducer: animationsReducer,
1414
environment: AnimationsEnvironment(
15-
mainQueue: self.scheduler
15+
mainQueue: self.mainQueue
1616
)
1717
)
1818

@@ -22,41 +22,41 @@ class AnimationTests: XCTestCase {
2222
$0.circleColor = .red
2323
}
2424

25-
self.scheduler.advance(by: 1)
25+
self.mainQueue.advance(by: 1)
2626
store.receive(.setColor(.blue)) {
2727
$0.circleColor = .blue
2828
}
2929

30-
self.scheduler.advance(by: 1)
30+
self.mainQueue.advance(by: 1)
3131
store.receive(.setColor(.green)) {
3232
$0.circleColor = .green
3333
}
3434

35-
self.scheduler.advance(by: 1)
35+
self.mainQueue.advance(by: 1)
3636
store.receive(.setColor(.orange)) {
3737
$0.circleColor = .orange
3838
}
3939

40-
self.scheduler.advance(by: 1)
40+
self.mainQueue.advance(by: 1)
4141
store.receive(.setColor(.pink)) {
4242
$0.circleColor = .pink
4343
}
4444

45-
self.scheduler.advance(by: 1)
45+
self.mainQueue.advance(by: 1)
4646
store.receive(.setColor(.purple)) {
4747
$0.circleColor = .purple
4848
}
4949

50-
self.scheduler.advance(by: 1)
50+
self.mainQueue.advance(by: 1)
5151
store.receive(.setColor(.yellow)) {
5252
$0.circleColor = .yellow
5353
}
5454

55-
self.scheduler.advance(by: 1)
55+
self.mainQueue.advance(by: 1)
5656
store.receive(.setColor(.white)) {
5757
$0.circleColor = .white
5858
}
5959

60-
self.scheduler.run()
60+
self.mainQueue.run()
6161
}
6262
}

Examples/CaseStudies/SwiftUICaseStudiesTests/02-Effects-CancellationTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class EffectsCancellationTests: XCTestCase {
5555
// test to fail, showing that we are exhaustively asserting that the effect truly is canceled and
5656
// will never emit.
5757
func testTrivia_CancelButtonCancelsRequest() {
58-
let scheduler = TestScheduler()
58+
let mainQueue = TestScheduler()
5959
let store = TestStore(
6060
initialState: EffectsCancellationState(),
6161
reducer: effectsCancellationReducer,
@@ -75,7 +75,7 @@ class EffectsCancellationTests: XCTestCase {
7575
}
7676

7777
func testTrivia_PlusMinusButtonsCancelsRequest() {
78-
let scheduler = TestScheduler()
78+
let mainQueue = TestScheduler()
7979
let store = TestStore(
8080
initialState: EffectsCancellationState(),
8181
reducer: effectsCancellationReducer,
@@ -92,6 +92,6 @@ class EffectsCancellationTests: XCTestCase {
9292
$0.count = 1
9393
$0.isTriviaRequestInFlight = false
9494
}
95-
scheduler.advance()
95+
mainQueue.advance()
9696
}
9797
}

Examples/CaseStudies/SwiftUICaseStudiesTests/02-Effects-TimersTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import XCTest
55
@testable import SwiftUICaseStudies
66

77
class TimersTests: XCTestCase {
8-
let scheduler = TestScheduler()
8+
let mainQueue = TestScheduler()
99

1010
func testStart() {
1111
let store = TestStore(
@@ -19,11 +19,11 @@ class TimersTests: XCTestCase {
1919
store.send(.toggleTimerButtonTapped) {
2020
$0.isTimerActive = true
2121
}
22-
self.scheduler.advance(by: 1)
22+
self.mainQueue.advance(by: 1)
2323
store.receive(.timerTicked) {
2424
$0.secondsElapsed = 1
2525
}
26-
self.scheduler.advance(by: 5)
26+
self.mainQueue.advance(by: 5)
2727
store.receive(.timerTicked) {
2828
$0.secondsElapsed = 2
2929
}

Examples/CaseStudies/SwiftUICaseStudiesTests/02-Effects-WebSocketTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class WebSocketTests: XCTestCase {
108108
webSocket.receive = { _ in .none }
109109
webSocket.sendPing = { _ in pingSubject.output.producer }
110110

111-
let scheduler = TestScheduler()
111+
let mainQueue = TestScheduler()
112112
let store = TestStore(
113113
initialState: WebSocketState(),
114114
reducer: webSocketReducer,
@@ -123,14 +123,14 @@ class WebSocketTests: XCTestCase {
123123
}
124124

125125
socketSubject.input.send(value: .didOpenWithProtocol(nil))
126-
scheduler.advance()
126+
mainQueue.advance()
127127
store.receive(.webSocket(.didOpenWithProtocol(nil))) {
128128
$0.connectivityState = .connected
129129
}
130130

131131
pingSubject.input.send(value: nil)
132-
scheduler.advance(by: 5)
133-
scheduler.advance(by: 5)
132+
mainQueue.advance(by: 5)
133+
mainQueue.advance(by: 5)
134134
store.receive(.pingResponse(nil))
135135

136136
store.send(.connectButtonTapped) {

Examples/CaseStudies/SwiftUICaseStudiesTests/04-HigherOrderReducers-LifecycleTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import XCTest
77

88
class LifecycleTests: XCTestCase {
99
func testLifecycle() {
10-
let scheduler = TestScheduler()
10+
let mainQueue = TestScheduler()
1111

1212
let store = TestStore(
1313
initialState: LifecycleDemoState(),
@@ -23,12 +23,12 @@ class LifecycleTests: XCTestCase {
2323

2424
store.send(.timer(.onAppear))
2525

26-
scheduler.advance(by: 1)
26+
mainQueue.advance(by: 1)
2727
store.receive(.timer(.action(.tick))) {
2828
$0.count = 1
2929
}
3030

31-
scheduler.advance(by: 1)
31+
mainQueue.advance(by: 1)
3232
store.receive(.timer(.action(.tick))) {
3333
$0.count = 2
3434
}

Examples/CaseStudies/SwiftUICaseStudiesTests/04-HigherOrderReducers-ReusableFavoritingTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import XCTest
55
@testable import SwiftUICaseStudies
66

77
class ReusableComponentsFavoritingTests: XCTestCase {
8-
let scheduler = TestScheduler()
8+
let mainQueue = TestScheduler()
99

1010
func testFavoriteButton() {
1111
let episodes: IdentifiedArrayOf<EpisodeState> = [
@@ -39,7 +39,7 @@ class ReusableComponentsFavoritingTests: XCTestCase {
3939
$0.episodes[id: episodes[0].id]?.isFavorite = true
4040
}
4141

42-
self.scheduler.advance()
42+
self.mainQueue.advance()
4343
store.receive(.episode(id: episodes[0].id, action: .favorite(.response(.success(true)))))
4444

4545
store.send(.episode(id: episodes[1].id, action: .favorite(.buttonTapped))) {
@@ -49,15 +49,15 @@ class ReusableComponentsFavoritingTests: XCTestCase {
4949
$0.episodes[id: episodes[1].id]?.isFavorite = false
5050
}
5151

52-
self.scheduler.advance()
52+
self.mainQueue.advance()
5353
store.receive(.episode(id: episodes[1].id, action: .favorite(.response(.success(false)))))
5454

5555
store.environment.favorite = { _, _ in .future { $0(.failure(error)) } }
5656
store.send(.episode(id: episodes[2].id, action: .favorite(.buttonTapped))) {
5757
$0.episodes[id: episodes[2].id]?.isFavorite = true
5858
}
5959

60-
self.scheduler.advance()
60+
self.mainQueue.advance()
6161
store.receive(
6262
.episode(
6363
id: episodes[2].id, action: .favorite(.response(.failure(FavoriteError(error: error)))))

Examples/CaseStudies/SwiftUICaseStudiesTests/04-HigherOrderReducers-ReusableOfflineDownloadsTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
1515
action: .self,
1616
environment: { $0 }
1717
)
18-
let scheduler = TestScheduler()
18+
let mainQueue = TestScheduler()
1919

2020
func testDownloadFlow() {
2121
var downloadClient = DownloadClient.unimplemented
@@ -39,18 +39,18 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
3939
}
4040

4141
self.downloadSubject.input.send(value: .updateProgress(0.2))
42-
self.scheduler.advance()
42+
self.mainQueue.advance()
4343
store.receive(.downloadClient(.success(.updateProgress(0.2)))) {
4444
$0.mode = .downloading(progress: 0.2)
4545
}
4646

4747
self.downloadSubject.input.send(value: .response(Data()))
48-
self.scheduler.advance(by: 1)
48+
self.mainQueue.advance(by: 1)
4949
store.receive(.downloadClient(.success(.response(Data())))) {
5050
$0.mode = .downloaded
5151
}
5252
self.downloadSubject.input.sendCompleted()
53-
self.scheduler.advance()
53+
self.mainQueue.advance()
5454
}
5555

5656
func testDownloadThrottling() {
@@ -75,16 +75,16 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
7575
}
7676

7777
self.downloadSubject.input.send(value: .updateProgress(0.5))
78-
self.scheduler.advance()
78+
self.mainQueue.advance()
7979
store.receive(.downloadClient(.success(.updateProgress(0.5)))) {
8080
$0.mode = .downloading(progress: 0.5)
8181
}
8282

8383
self.downloadSubject.input.send(value: .updateProgress(0.6))
84-
self.scheduler.advance(by: 0.5)
84+
self.mainQueue.advance(by: 0.5)
8585

8686
self.downloadSubject.input.send(value: .updateProgress(0.7))
87-
self.scheduler.advance(by: 0.5)
87+
self.mainQueue.advance(by: 0.5)
8888
store.receive(.downloadClient(.success(.updateProgress(0.7)))) {
8989
$0.mode = .downloading(progress: 0.7)
9090
}
@@ -160,13 +160,13 @@ class ReusableComponentsDownloadComponentTests: XCTestCase {
160160
}
161161

162162
self.downloadSubject.input.send(value: .response(Data()))
163-
self.scheduler.advance(by: 1)
163+
self.mainQueue.advance(by: 1)
164164
store.receive(.downloadClient(.success(.response(Data())))) {
165165
$0.alert = nil
166166
$0.mode = .downloaded
167167
}
168168
self.downloadSubject.input.sendCompleted()
169-
self.scheduler.advance()
169+
self.mainQueue.advance()
170170
}
171171

172172
func testDeleteDownloadFlow() {

Examples/Search/SearchTests/SearchTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import XCTest
55
@testable import Search
66

77
class SearchTests: XCTestCase {
8-
let scheduler = TestScheduler()
8+
let mainQueue = TestScheduler()
99

1010
func testSearchAndClearQuery() {
1111
let store = TestStore(
@@ -21,7 +21,7 @@ class SearchTests: XCTestCase {
2121
store.send(.searchQueryChanged("S")) {
2222
$0.searchQuery = "S"
2323
}
24-
self.scheduler.advance(by: 0.3)
24+
self.mainQueue.advance(by: 0.3)
2525
store.receive(.searchResponse(.success(.mock))) {
2626
$0.results = Search.mock.results
2727
}
@@ -45,7 +45,7 @@ class SearchTests: XCTestCase {
4545
store.send(.searchQueryChanged("S")) {
4646
$0.searchQuery = "S"
4747
}
48-
self.scheduler.advance(by: 0.3)
48+
self.mainQueue.advance(by: 0.3)
4949
store.receive(.searchResponse(.failure(WeatherClient.Failure())))
5050
}
5151

@@ -65,7 +65,7 @@ class SearchTests: XCTestCase {
6565
store.send(.searchQueryChanged("S")) {
6666
$0.searchQuery = "S"
6767
}
68-
self.scheduler.advance(by: 0.2)
68+
self.mainQueue.advance(by: 0.2)
6969
store.send(.searchQueryChanged("")) {
7070
$0.searchQuery = ""
7171
}
@@ -99,7 +99,7 @@ class SearchTests: XCTestCase {
9999
store.send(.searchResultTapped(specialResult)) {
100100
$0.resultForecastRequestInFlight = specialResult
101101
}
102-
self.scheduler.advance()
102+
self.mainQueue.advance()
103103
store.receive(.forecastResponse(42, .success(.mock))) {
104104
$0.resultForecastRequestInFlight = nil
105105
$0.weather = SearchState.Weather(
@@ -161,7 +161,7 @@ class SearchTests: XCTestCase {
161161
store.send(.searchResultTapped(specialResult)) {
162162
$0.resultForecastRequestInFlight = specialResult
163163
}
164-
self.scheduler.advance()
164+
self.mainQueue.advance()
165165
store.receive(.forecastResponse(42, .success(.mock))) {
166166
$0.resultForecastRequestInFlight = nil
167167
$0.weather = SearchState.Weather(
@@ -211,7 +211,7 @@ class SearchTests: XCTestCase {
211211
store.send(.searchResultTapped(results.first!)) {
212212
$0.resultForecastRequestInFlight = results.first!
213213
}
214-
self.scheduler.advance()
214+
self.mainQueue.advance()
215215
store.receive(.forecastResponse(1, .failure(WeatherClient.Failure()))) {
216216
$0.resultForecastRequestInFlight = nil
217217
}

Examples/TicTacToe/tic-tac-toe/Tests/LoginCoreTests/LoginCoreTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class LoginCoreTests: XCTestCase {
6868
authenticationClient.twoFactor = { _ in
6969
Effect(value: AuthenticationResponse(token: "deadbeefdeadbeef", twoFactorRequired: false))
7070
}
71-
let scheduler = TestScheduler()
71+
let mainQueue = TestScheduler()
7272

7373
let store = TestStore(
7474
initialState: LoginState(),
@@ -89,7 +89,7 @@ class LoginCoreTests: XCTestCase {
8989
store.send(.loginButtonTapped) {
9090
$0.isLoginRequestInFlight = true
9191
}
92-
scheduler.advance()
92+
mainQueue.advance()
9393
store.receive(
9494
.loginResponse(
9595
.success(AuthenticationResponse(token: "deadbeefdeadbeef", twoFactorRequired: true))

0 commit comments

Comments
 (0)