Skip to content

Instantly share code, notes, and snippets.

@thexande
Last active December 21, 2018 18:23
Show Gist options
  • Save thexande/b0a13efb103babffdee12869c983f579 to your computer and use it in GitHub Desktop.
Save thexande/b0a13efb103babffdee12869c983f579 to your computer and use it in GitHub Desktop.
extension WorldAPITests {
func test_CountriesQueryParsingFailure() {
// Invalid JSON response
let results: JSONObject = ["🍔": 0xDEADBEEF]
let query = CountriesQuery()
withCache(initialRecords: [:]) { cache in
let store = ApolloStore(cache: cache)
let client = ApolloClient(networkTransport: MockNetworkTransport(body: results,
simulateNetworkFailure: false),
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.parsing)
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