in source/UberRidesTests/RideRequestViewRequestingBehaviorTests.swift [75:106]
func testPresentModal() {
class UIViewControllerMock : UIViewController {
let testClosure: (UIViewController) -> ()
fileprivate init(testClosure: @escaping (UIViewController) -> ()) {
self.testClosure = testClosure
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) {
self.testClosure(viewControllerToPresent)
return
}
}
let expectation = self.expectation(description: "ModalRideViewController is presented")
let expectationClosure: (UIViewController) -> () = { viewController in
XCTAssertTrue(viewController is ModalRideRequestViewController)
expectation.fulfill()
}
let baseVC = UIViewControllerMock(testClosure: expectationClosure)
let initialLoginManger = LoginManager(loginType: .native)
let behavior = RideRequestViewRequestingBehavior(presentingViewController: baseVC, loginManager: initialLoginManger)
behavior.requestRide(parameters: RideParametersBuilder().build())
waitForExpectations(timeout: 2.0) {error in
XCTAssertNil(error)
}
}