in source/UberCoreTests/UberAppDelegateTests.swift [96:126]
func testDidFinishLaunchingCallsOpenURL_whenLaunchURL() {
let expectation = self.expectation(description: "open URL called")
let appDelegate = UberAppDelegate.shared
let testApp = UIApplication.shared
let loginManagerMock = LoginManagingProtocolMock()
guard let testURL = URL(string: "http://www.google.com") else {
XCTFail()
return
}
let testSourceApplication = "testSource"
let testAnnotation = "annotation"
var launchOptions = [UIApplicationLaunchOptionsKey: Any]()
launchOptions[UIApplicationLaunchOptionsKey.url] = testURL as Any
launchOptions[UIApplicationLaunchOptionsKey.sourceApplication] = testSourceApplication as Any
launchOptions[UIApplicationLaunchOptionsKey.annotation] = testAnnotation as Any
let urlClosure: ((UIApplication, URL, String?, Any?) -> Bool) = { application, url, source, annotation in
XCTAssertEqual(application, testApp)
XCTAssertEqual(url, testURL)
XCTAssertEqual(source, testSourceApplication)
XCTAssertEqual(annotation as? String, testAnnotation)
expectation.fulfill()
return true
}
loginManagerMock.openURLClosure = urlClosure
appDelegate.loginManager = loginManagerMock
XCTAssertTrue(appDelegate.application(testApp, didFinishLaunchingWithOptions: launchOptions))
XCTAssertNil(appDelegate.loginManager)
waitForExpectations(timeout: 0.2, handler: nil)
}