From 4ad76dc368eb7623fd4a9421e0a204f6df76df1c Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Tue, 20 Sep 2022 12:34:30 +0200 Subject: [PATCH] Update tests --- .../MyContactFeatureTests.swift | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Examples/xx-messenger/Tests/MyContactFeatureTests/MyContactFeatureTests.swift b/Examples/xx-messenger/Tests/MyContactFeatureTests/MyContactFeatureTests.swift index 4193e935..9c30f7df 100644 --- a/Examples/xx-messenger/Tests/MyContactFeatureTests/MyContactFeatureTests.swift +++ b/Examples/xx-messenger/Tests/MyContactFeatureTests/MyContactFeatureTests.swift @@ -174,6 +174,41 @@ final class MyContactFeatureTests: XCTestCase { } } + func testLoadFactsFromClientFailure() { + struct Failure: Error {} + let failure = Failure() + + let store = TestStore( + initialState: MyContactState(), + reducer: myContactReducer, + environment: .unimplemented + ) + + store.environment.mainQueue = .immediate + store.environment.bgQueue = .immediate + store.environment.messenger.e2e.get = { + var e2e: E2E = .unimplemented + e2e.getContact.run = { + var contact: XXClient.Contact = .unimplemented(Data()) + contact.getIdFromContact.run = { _ in throw failure } + return contact + } + return e2e + } + + store.send(.loadFactsTapped) { + $0.isLoadingFacts = true + } + + store.receive(.didFail(failure.localizedDescription)) { + $0.alert = .error(failure.localizedDescription) + } + + store.receive(.set(\.$isLoadingFacts, false)) { + $0.isLoadingFacts = false + } + } + func testErrorAlert() { let store = TestStore( initialState: MyContactState(), -- GitLab