Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jacobsapps/50a0cb1be11ebe88bc4141299670d33a to your computer and use it in GitHub Desktop.
Save jacobsapps/50a0cb1be11ebe88bc4141299670d33a to your computer and use it in GitHub Desktop.
func test_refresh_loadsDataFromAPI() {
// given
mockAPI.stubFetchResponse = .success([])
let exp = expectation(description: #function)
// when
viewModel.refresh()
mockAPI.didFetchData = { exp.fulfill() }
// then
waitForExpectations(timeout: 1)
XCTAssertTrue(mockAPI.fetchDataCalled) // ✅ pass
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment