func testWithFromViewControllerMissingTransitionCoordinator()

in FBSDKCoreKit/FBSDKCoreKitTests/Internal/BridgeAPI/BridgeAPIOpenUrlWithSafariTests.swift [155:210]


  func testWithFromViewControllerMissingTransitionCoordinator() {
    let spy = ViewControllerSpy.makeDefaultSpy()
    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
    )

    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"
    )
    XCTAssertNil(
      urlOpener.capturedOpenURL,
      "Should not try to open a url when the request cannot provide one"
    )
    XCTAssertNil(api.authenticationSessionCompletionHandler)
    XCTAssertNil(api.authenticationSession)
    assertExpectingBackgroundAndPendingUrlOpener()
    XCTAssertTrue(didInvokeHandler)
  }