<Description> : Adding test for timer runThisEvery.

<Type> : test
This commit is contained in:
Arunav Sanyal 2016-11-27 23:32:05 -08:00 committed by Sanyal
parent bbfbfa0b1b
commit 64be3cb8da
1 changed files with 20 additions and 0 deletions

View File

@ -26,5 +26,25 @@ class TimerTests: XCTestCase {
XCTAssertTrue(methodCalled)
}
}
public func testAfterEveryPositiveCase() {
let testAfterEveryExpectation = expectation(description: "testAfterDelay")
var methodCalledTimes = 0
_ = Timer.runThisEvery(seconds: 1) { (timer) -> Void in
methodCalledTimes += 1
if (methodCalledTimes == 3) {
timer?.invalidate()
testAfterEveryExpectation.fulfill()
}
}
self.waitForExpectations(timeout: 10) { completion in
XCTAssertEqual(methodCalledTimes, 3)
}
}
}