Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 682c20f

Browse files
committed
Expose SocialService.User convenience computed var in SocialService
1 parent 7e1ae2b commit 682c20f

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

WordPressAuthenticator.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
3F86A84629D2A306005D20C0 /* WordPressAuthenticatorDelegateSpy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F86A84529D2A306005D20C0 /* WordPressAuthenticatorDelegateSpy.swift */; };
3939
3F86A84829D2A42D005D20C0 /* WordPressAuthenticator+TestsUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F86A84729D2A42D005D20C0 /* WordPressAuthenticator+TestsUtils.swift */; };
4040
3F86A84A29D2A982005D20C0 /* LoginViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F86A84929D2A982005D20C0 /* LoginViewControllerTests.swift */; };
41+
3F86A84E29D3B53D005D20C0 /* SocialServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F86A84D29D3B53D005D20C0 /* SocialServiceTests.swift */; };
4142
3F879FD5293A3AB6005C2B48 /* OAuthTokenRequestBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F879FD4293A3AB6005C2B48 /* OAuthTokenRequestBody.swift */; };
4243
3F879FD7293A44F2005C2B48 /* OAuthTokenRequestBodyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F879FD6293A44F2005C2B48 /* OAuthTokenRequestBodyTests.swift */; };
4344
3F879FD9293A48B2005C2B48 /* OAuthTokenResponseBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F879FD8293A48B2005C2B48 /* OAuthTokenResponseBody.swift */; };
@@ -294,6 +295,7 @@
294295
3F86A84529D2A306005D20C0 /* WordPressAuthenticatorDelegateSpy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorDelegateSpy.swift; sourceTree = "<group>"; };
295296
3F86A84729D2A42D005D20C0 /* WordPressAuthenticator+TestsUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WordPressAuthenticator+TestsUtils.swift"; sourceTree = "<group>"; };
296297
3F86A84929D2A982005D20C0 /* LoginViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewControllerTests.swift; sourceTree = "<group>"; };
298+
3F86A84D29D3B53D005D20C0 /* SocialServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialServiceTests.swift; sourceTree = "<group>"; };
297299
3F879FD4293A3AB6005C2B48 /* OAuthTokenRequestBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuthTokenRequestBody.swift; sourceTree = "<group>"; };
298300
3F879FD6293A44F2005C2B48 /* OAuthTokenRequestBodyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuthTokenRequestBodyTests.swift; sourceTree = "<group>"; };
299301
3F879FD8293A48B2005C2B48 /* OAuthTokenResponseBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuthTokenResponseBody.swift; sourceTree = "<group>"; };
@@ -717,6 +719,7 @@
717719
isa = PBXGroup;
718720
children = (
719721
B501C040208FC52500D1E58F /* LoginFacadeTests.m */,
722+
3F86A84D29D3B53D005D20C0 /* SocialServiceTests.swift */,
720723
);
721724
path = Services;
722725
sourceTree = "<group>";
@@ -1549,6 +1552,7 @@
15491552
buildActionMask = 2147483647;
15501553
files = (
15511554
3F4E64782990BBD4000DB555 /* IDTokenTests.swift in Sources */,
1555+
3F86A84E29D3B53D005D20C0 /* SocialServiceTests.swift in Sources */,
15521556
3F879FDB293A49AA005C2B48 /* NewGoogleAuthenticatorTests.swift in Sources */,
15531557
F18DF0E5252500A600D83AFE /* WordPressAuthenticatorTests-Bridging-Header.h in Sources */,
15541558
3FE8071529364C410088420C /* Result+ConvenienceInitTests.swift in Sources */,

WordPressAuthenticator/Services/SocialService.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ public enum SocialService {
99
public let fullName: String
1010
}
1111

12+
public var user: User {
13+
switch self {
14+
case .google(let user): return user
15+
case .apple(let user): return user
16+
}
17+
}
18+
1219
/// Google's Signup Linked Account
1320
///
1421
case google(user: User)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@testable import WordPressAuthenticator
2+
import XCTest
3+
4+
class SocialServiceTests: XCTestCase {
5+
6+
func testSocialServiceUserApple() throws {
7+
let socialService = SocialService.apple(user: .init(email: "[email protected]", fullName: "Full Name"))
8+
9+
XCTAssertEqual(socialService.user.fullName, "Full Name")
10+
XCTAssertEqual(socialService.user.email, "[email protected]")
11+
}
12+
13+
func testSocialServiceUserGoogle() throws {
14+
let socialService = SocialService.google(user: .init(email: "[email protected]", fullName: "Name Full"))
15+
16+
XCTAssertEqual(socialService.user.fullName, "Name Full")
17+
XCTAssertEqual(socialService.user.email, "[email protected]")
18+
}
19+
}

0 commit comments

Comments
 (0)