Clean up documentation

pull/175/head
nielsandriesse 5 years ago
parent 34d79210c0
commit e879334b3b

@ -2,22 +2,26 @@ import XCTest
extension XCTestCase { extension XCTestCase {
/// Simple helper for asynchronous testing. /// A helper for asynchronous testing.
/// Usage in XCTestCase method: ///
/// func testSomething() { /// Usage example:
/// doAsyncThings() ///
/// eventually { /// ```
/// /* XCTAssert goes here... */ /// func testSomething() {
/// } /// doAsyncThings()
/// } /// eventually {
/// Cloure won't execute until timeout is met. You need to pass in an /// /* XCTAssert goes here... */
/// timeout long enough for your asynchronous process to finish, if it's /// }
/// }
/// ```
///
/// The provided closure won't execute until `timeout` seconds have passed. Pass
/// in a timeout long enough for your asynchronous process to finish if it's
/// expected to take more than the default 0.1 second. /// expected to take more than the default 0.1 second.
/// ///
/// - Parameters: /// - Parameters:
/// - timeout: amout of time in seconds to wait before executing the /// - timeout: number of seconds to wait before executing `closure`.
/// closure. /// - closure: a closure to execute when `timeout` seconds have passed.
/// - closure: a closure to execute when `timeout` seconds has passed
func eventually(timeout: TimeInterval = 0.1, closure: @escaping () -> Void) { func eventually(timeout: TimeInterval = 0.1, closure: @escaping () -> Void) {
let expectation = self.expectation(description: "") let expectation = self.expectation(description: "")
expectation.fulfillAfter(timeout) expectation.fulfillAfter(timeout)
@ -31,7 +35,7 @@ extension XCTestExpectation {
/// Call `fulfill()` after some time. /// Call `fulfill()` after some time.
/// ///
/// - Parameter time: amout of time after which `fulfill()` will be called. /// - Parameter time: number of seconds after which `fulfill()` will be called.
func fulfillAfter(_ time: TimeInterval) { func fulfillAfter(_ time: TimeInterval) {
DispatchQueue.main.asyncAfter(deadline: .now() + time) { DispatchQueue.main.asyncAfter(deadline: .now() + time) {
self.fulfill() self.fulfill()
Loading…
Cancel
Save