View AppleAuthenticationProviderTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_didFetchAuthorizationCredential_shouldCallDelegatesDidCompleteWithCredential() { | |
//Given | |
let sut = AppleAuthenticationProvider() | |
sut.delegate = delegateSpy | |
let mockedCredential: ASAuthorizationAppleIDCredentialProtocol = MockedCredential() | |
//When | |
sut.didFetch(authorizationCredential: mockedCredential) | |
//Then |
View AppleAuthenticationProvider.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { | |
// Call didFetch(authorizationCredential:) | |
} | |
//To test didFetch(authorizationCredential:), mock ASAuthorizationAppleIDCredentialProtocol and | |
//assert that your delegate is being called properly | |
func didFetch(authorizationCredential: ASAuthorizationAppleIDCredentialProtocol) { | |
let credential = mapCredential(from: authorizationCredential) | |
delegate?.didCompleteWith(credential: credential) | |
} |