, FreeApiService. , ( ), FreeApiService . , .
, (- ) (- ), . :
func testConnect_ShouldCallCompletionHandlerWithTrueStatusAndNilError() {
let apiService = FreeApiService(httpClient: httpClient)
var capturedStatus: Bool?
var capturedError: Error?
let promise = expectation(description: "Completion handler invoked")
apiService.connect() {(status, error) in
capturedStatus = status
capturedError = error
promise.fulfill()
}
waitForExpectations(timeout: 5, handler: nil)
XCTAssertTrue(capturedStatus ?? false, "status")
XCTAssertNil(capturedError, "error")
}
, waitForExpectations 5 . .
. , , , :
.
... ! . , , . . . , , . , :
, , , . .