Last active
December 21, 2018 18:23
-
-
Save thexande/b0a13efb103babffdee12869c983f579 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_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