-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
81 additions
and
21 deletions.
There are no files selected for viewing
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
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
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
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
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
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
19 changes: 19 additions & 0 deletions
19
WordPressAuthenticatorTests/Services/SocialServiceTests.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@testable import WordPressAuthenticator | ||
import XCTest | ||
|
||
class SocialServiceTests: XCTestCase { | ||
|
||
func testSocialServiceUserApple() throws { | ||
let socialService = SocialService.apple(user: .init(email: "[email protected]", fullName: "Full Name")) | ||
|
||
XCTAssertEqual(socialService.user.fullName, "Full Name") | ||
XCTAssertEqual(socialService.user.email, "[email protected]") | ||
} | ||
|
||
func testSocialServiceUserGoogle() throws { | ||
let socialService = SocialService.google(user: .init(email: "[email protected]", fullName: "Name Full")) | ||
|
||
XCTAssertEqual(socialService.user.fullName, "Name Full") | ||
XCTAssertEqual(socialService.user.email, "[email protected]") | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
WordPressAuthenticatorTests/SingIn/LoginViewControllerTests.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@testable import WordPressAuthenticator | ||
import XCTest | ||
|
||
class LoginViewControllerTests: XCTestCase { | ||
|
||
// showSignupEpilogue with loginFields.meta.appleUser set will pass SocialService.apple to | ||
// the delegate | ||
func testShowingSignupEpilogueWithGoogleUser() throws { | ||
WordPressAuthenticator.initializeForTesting() | ||
let delegateSpy = WordPressAuthenticatorDelegateSpy() | ||
WordPressAuthenticator.shared.delegate = delegateSpy | ||
|
||
// This might be unnecessary because delegateSpy should be deallocated once the test method finished. | ||
// Leaving it here, just in case. | ||
addTeardownBlock { | ||
WordPressAuthenticator.shared.delegate = nil | ||
} | ||
|
||
let sut = LoginViewController() | ||
// We need to embed the SUT in a navigation controller because it expects its | ||
// navigationController property to not be nil. | ||
_ = UINavigationController(rootViewController: sut) | ||
|
||
sut.loginFields.meta.googleUser = SocialService.User(email: "[email protected]", fullName: "Full Name") | ||
|
||
sut.showSignupEpilogue(for: AuthenticatorCredentials()) | ||
|
||
let socialService = try XCTUnwrap(delegateSpy.socialService) | ||
guard case .google(let user) = socialService else { | ||
return XCTFail("Expected Google social service, got \(socialService) instead") | ||
} | ||
XCTAssertEqual(user.fullName, "Full Name") | ||
XCTAssertEqual(user.email, "[email protected]") | ||
} | ||
} |