Skip to content

Instantly share code, notes, and snippets.

@victorpanitz
Last active August 15, 2020 21:01
Show Gist options
  • Save victorpanitz/2326399a746a0ee8d3f93ad2871f71f7 to your computer and use it in GitHub Desktop.
Save victorpanitz/2326399a746a0ee8d3f93ad2871f71f7 to your computer and use it in GitHub Desktop.
func test_cancellAllTasks_givenExistsActiveTasks_shouldCancellAllOfThem() {
...
let cancelTasksExpectation = XCTestExpectation(description: "cancelTasksExpectation")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
sut.session.getAllTasks { tasks in
activeTasksCount = tasks.count
cancelTasksExpectation.fulfill()
}
}
wait(for: [cancelTasksExpectation], timeout: 0.2)
XCTAssertEqual(activeTasksCount, 0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment