Created
December 20, 2018 05:03
-
-
Save thexande/c977e72afbd02e2a9ffcc6bfebd487f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension WorldAPITests { | |
func test_CountriesQueryNetworkFailure() { | |
guard let results = MockGraphQLQuery.countries.responseObject else { | |
XCTFail() | |
return | |
} | |
let query = CountriesQuery() | |
withCache(initialRecords: [:]) { cache in | |
let store = ApolloStore(cache: cache) | |
let transport = MockNetworkTransport(body: results, | |
simulateNetworkFailure: true) | |
let client = ApolloClient(networkTransport: transport, | |
store: store) | |
let worldStore = World.Store(client: client) | |
let expectation = self.expectation(description: "Fetching query") | |
worldStore.fetchAllCountries { result in | |
defer { | |
expectation.fulfill() | |
} | |
switch result { | |
case let .failure(error): | |
XCTAssertEqual(error, World.StoreError.network) | |
return | |
case .success: | |
XCTFail() | |
} | |
} | |
self.waitForExpectations(timeout: 5, handler: nil) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment