Skip to content

Instantly share code, notes, and snippets.

@iSapozhnik
Created August 30, 2021 11:58
Show Gist options
  • Save iSapozhnik/8bd714e71c392bebef27fe58a6004ac3 to your computer and use it in GitHub Desktop.
Save iSapozhnik/8bd714e71c392bebef27fe58a6004ac3 to your computer and use it in GitHub Desktop.
func test(with identifier: String = #function, body: (XCTestExpectation) -> Void) {
let expectation = expectation(description: identifier)
body(expectation)
waitForExpectations(timeout: 0.5)
}
func testAscending() {
let a = [1]
test { expectation in
a.publisher.sink { value in
XCTAssert(value == 2)
expectation.fulfill()
}.store(in: &cancellables)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment