diff --git a/0097-adaptive-state-management-pt4/PrimeTime/CounterTests/CounterTests.swift b/0097-adaptive-state-management-pt4/PrimeTime/CounterTests/CounterTests.swift index 9851481b..827ba6b9 100644 --- a/0097-adaptive-state-management-pt4/PrimeTime/CounterTests/CounterTests.swift +++ b/0097-adaptive-state-management-pt4/PrimeTime/CounterTests/CounterTests.swift @@ -8,7 +8,7 @@ import XCTest class CounterTests: XCTestCase { func testSnapshots() { - let store = Store(initialValue: CounterViewState(), reducer: counterViewReducer, environment: { _ in .sync { 17 } }) + let store = Store(initialValue: CounterFeatureState(), reducer: counterViewReducer, environment: { _ in .sync { 17 } }) let view = CounterView(store: store) let vc = UIHostingController(rootView: view) @@ -16,13 +16,13 @@ class CounterTests: XCTestCase { assertSnapshot(matching: vc, as: .windowedImage) - store.send(.counter(.incrTapped)) + view.viewStore.send(.incrTapped) assertSnapshot(matching: vc, as: .windowedImage) - store.send(.counter(.incrTapped)) + view.viewStore.send(.incrTapped) assertSnapshot(matching: vc, as: .windowedImage) - store.send(.counter(.nthPrimeButtonTapped)) + view.viewStore.send(.nthPrimeButtonTapped) assertSnapshot(matching: vc, as: .windowedImage) var expectation = self.expectation(description: "wait") @@ -32,7 +32,7 @@ class CounterTests: XCTestCase { self.wait(for: [expectation], timeout: 0.5) assertSnapshot(matching: vc, as: .windowedImage) - store.send(.counter(.alertDismissButtonTapped)) + view.viewStore.send(.alertDismissButtonTapped) expectation = self.expectation(description: "wait") DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { expectation.fulfill() @@ -40,19 +40,19 @@ class CounterTests: XCTestCase { self.wait(for: [expectation], timeout: 0.5) assertSnapshot(matching: vc, as: .windowedImage) - store.send(.counter(.isPrimeButtonTapped)) + view.viewStore.send(.isPrimeButtonTapped) assertSnapshot(matching: vc, as: .windowedImage) - store.send(.primeModal(.saveFavoritePrimeTapped)) + store.view.send(.primeModal(.saveFavoritePrimeTapped)) assertSnapshot(matching: vc, as: .windowedImage) - store.send(.counter(.primeModalDismissed)) + view.viewStore.send(.primeModalDismissed) assertSnapshot(matching: vc, as: .windowedImage) } func testIncrDecrButtonTapped() { assert( - initialValue: CounterViewState(count: 2), + initialValue: CounterFeatureState(count: 2), reducer: counterViewReducer, environment: { _ in .sync { 17 } }, steps: @@ -64,20 +64,20 @@ class CounterTests: XCTestCase { func testNthPrimeButtonHappyFlow() { assert( - initialValue: CounterViewState( + initialValue: CounterFeatureState( alertNthPrime: nil, count: 7, - isNthPrimeButtonDisabled: false + isNthPrimeRequestInFlight: false ), reducer: counterViewReducer, environment: { _ in .sync { 17 } }, steps: - Step(.send, .counter(.nthPrimeButtonTapped)) { - $0.isNthPrimeButtonDisabled = true + Step(.send, .counter(CounterAction.requestNthPrime)) { + $0.isNthPrimeRequestInFlight = true }, Step(.receive, .counter(.nthPrimeResponse(n: 7, prime: 17))) { $0.alertNthPrime = PrimeAlert(n: $0.count, prime: 17) - $0.isNthPrimeButtonDisabled = false + $0.isNthPrimeRequestInFlight = false }, Step(.send, .counter(.alertDismissButtonTapped)) { $0.alertNthPrime = nil @@ -87,26 +87,26 @@ class CounterTests: XCTestCase { func testNthPrimeButtonUnhappyFlow() { assert( - initialValue: CounterViewState( + initialValue: CounterFeatureState( alertNthPrime: nil, count: 7, - isNthPrimeButtonDisabled: false + isNthPrimeRequestInFlight: false ), reducer: counterViewReducer, environment: { _ in .sync { nil } }, steps: - Step(.send, .counter(.nthPrimeButtonTapped)) { - $0.isNthPrimeButtonDisabled = true + Step(.send, .counter(.requestNthPrime)) { + $0.isNthPrimeRequestInFlight = true }, Step(.receive, .counter(.nthPrimeResponse(n: 7, prime: nil))) { - $0.isNthPrimeButtonDisabled = false + $0.isNthPrimeRequestInFlight = false } ) } func testPrimeModal() { assert( - initialValue: CounterViewState( + initialValue: CounterFeatureState( count: 1, favoritePrimes: [3, 5] ), diff --git a/0097-adaptive-state-management-pt4/PrimeTime/CounterTests/__Snapshots__/CounterTests/testSnapshots.4.png b/0097-adaptive-state-management-pt4/PrimeTime/CounterTests/__Snapshots__/CounterTests/testSnapshots.4.png index ed1a854e..2cffd171 100644 Binary files a/0097-adaptive-state-management-pt4/PrimeTime/CounterTests/__Snapshots__/CounterTests/testSnapshots.4.png and b/0097-adaptive-state-management-pt4/PrimeTime/CounterTests/__Snapshots__/CounterTests/testSnapshots.4.png differ diff --git a/0097-adaptive-state-management-pt4/PrimeTime/PrimeTime.xcodeproj/xcshareddata/xcschemes/PrimeTime.xcscheme b/0097-adaptive-state-management-pt4/PrimeTime/PrimeTime.xcodeproj/xcshareddata/xcschemes/PrimeTime.xcscheme index d64f316c..c8018bd7 100644 --- a/0097-adaptive-state-management-pt4/PrimeTime/PrimeTime.xcodeproj/xcshareddata/xcschemes/PrimeTime.xcscheme +++ b/0097-adaptive-state-management-pt4/PrimeTime/PrimeTime.xcodeproj/xcshareddata/xcschemes/PrimeTime.xcscheme @@ -39,7 +39,7 @@ + skipped = "NO"> + skipped = "NO"> + skipped = "NO"> + skipped = "NO"> + skipped = "NO">