in FBSDKCoreKit/FBSDKCoreKitTests/Internal/BridgeAPI/BridgeAPIOpenUrlWithSafariTests.swift [212:274]
func testWithFromViewControllerWithTransitionCoordinator() {
let spy = ViewControllerSpy.makeDefaultSpy()
let coordinator = TestViewControllerTransitionCoordinator()
spy.stubbedTransitionCoordinator = coordinator
loginManager.stubbedIsAuthenticationURL = false
api.expectingBackground = true
var didInvokeHandler = false
let handler: SuccessBlock = { success, error in
XCTAssertTrue(success, "Should call the handler with success")
XCTAssertNil(error, "Should not call the handler with an error")
didInvokeHandler = true
}
api.openURLWithSafariViewController(
url: sampleUrl,
sender: loginManager,
from: spy,
handler: handler
)
// swiftlint:disable:next force_unwrapping
coordinator.capturedAnimateAlongsideTransitionCompletion!(
TestViewControllerTransitionCoordinator()
)
XCTAssertNil(
urlOpener.capturedOpenURL,
"Should not try to open a url when the request cannot provide one"
)
XCTAssertNil(api.authenticationSessionCompletionHandler)
XCTAssertNil(api.authenticationSession)
let safariVc = api.safariViewController
XCTAssertNotNil(
safariVc,
"Should create and set a safari view controller for display"
)
XCTAssertEqual(
safariVc?.modalPresentationStyle,
.overFullScreen,
"Should set the correct modal presentation style"
)
XCTAssertEqual(
safariVc?.delegate as? BridgeAPI,
api,
"Should set the safari view controller delegate to the bridge api"
)
XCTAssertEqual(
spy.capturedPresentViewController,
safariVc?.parent,
"Should present the view controller containing the safari view controller"
)
XCTAssertTrue(
spy.capturedPresentViewControllerAnimated,
"Should animate presenting the safari view controller"
)
XCTAssertNil(
spy.capturedPresentViewControllerCompletion,
"Should not pass a completion handler to the safari vc presentation"
)
assertExpectingBackgroundAndPendingUrlOpener()
XCTAssertTrue(didInvokeHandler)
}