File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -39,4 +39,25 @@ final class ViewModelTests: XCTestCase {
3939 XCTAssertEqual ( serviceSpy. fetchConfigArgCallsCount, 2 )
4040 XCTAssertEqual ( serviceSpy. fetchConfigArgReceivedInvocations, [ 1 , 2 ] )
4141 }
42+
43+ func testThrowableError( ) async throws {
44+ serviceSpy. fetchConfigArgThrowableError = CustomError . expected
45+
46+ do {
47+ try await sut. saveConfig ( )
48+ XCTFail ( " An error should have been thrown by the sut " )
49+ } catch CustomError . expected {
50+ XCTAssertEqual ( serviceSpy. fetchConfigArgCallsCount, 1 )
51+ XCTAssertEqual ( serviceSpy. fetchConfigArgReceivedInvocations, [ 1 ] )
52+ XCTAssertTrue ( sut. config. isEmpty)
53+ } catch {
54+ XCTFail ( " Unexpected error catched " )
55+ }
56+ }
57+ }
58+
59+ extension ViewModelTests {
60+ enum CustomError : Error {
61+ case expected
62+ }
4263}
You can’t perform that action at this time.
0 commit comments