Last active
December 26, 2016 17:53
-
-
Save danielCarlosCE/25f889e1936b6cc01f346eb863802e6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func setUp() { | |
super.setUp() | |
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil) | |
readerVC = mainStoryboard.instantiateViewController(withIdentifier: "ReaderViewController") as! ReaderViewController | |
readerVC.dataSource = MockDataSource() | |
readerVC.codeReader = mockReader | |
//force the life cycle to be called | |
let window = UIApplication.shared.delegate!.window! | |
window!.rootViewController = readerVC | |
} | |
func testItFiresRightEventWhenKnownCodeIsRead() { | |
let exp = expectation(description: "calls didFindCard") | |
//given | |
var didFindCardWasCalled = false | |
readerVC.didFindCard = { _ in | |
didFindCardWasCalled = true | |
exp.fulfill() | |
} | |
//when | |
mockReader.completion?("123") | |
//then | |
waitForExpectations(timeout: 3) { error in | |
XCTAssert(didFindCardWasCalled) | |
XCTAssertNil(error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment