Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1
- func testHasAddBarButton() {
- let barButtonItem = controller.navigationItem.rightBarButtonItem
- let itemTypeRawValue = barButtonItem?.value(forKey: "systemItem") as! Int
- // 2
- XCTAssertEqual(UIBarButtonSystemItem(rawValue: itemTypeRawValue), UIBarButtonSystemItem.add)
- }
- //3
- func testAddButtonPresentsAddItemViewController() {
- XCTAssertNil(controller.presentedViewController)
- // 4
- guard let addButton = controller.navigationItem.rightBarButtonItem,
- let target = addButton.target,
- let action = addButton.action else {
- return XCTFail("Controller should have a right bar button item with a target and an action")
- }
- UIApplication.shared.keyWindow?.rootViewController = controller
- // 5
- XCTAssertEqual(target.identifier, "presentInputViewController")
- // 6
- target.performSelector(
- onMainThread: action,
- with: addButton,
- waitUntilDone: true
- )
- // 7
- guard let inputViewController = controller.presentedViewController as? InputViewController else {
- return XCTFail()
- }
- XCTAssertNotNil(inputViewController.titleTextField)
- }
Add Comment
Please, Sign In to add comment