@@ -10,7 +10,6 @@ import FirebaseCore
10
10
@testable import FirebaseSwiftUIExample
11
11
import Testing
12
12
13
- let kEmailAddress = " [email protected] "
14
13
let kPassword = " 123456 "
15
14
16
15
struct FirebaseSwiftUIExampleTests {
@@ -25,6 +24,12 @@ struct FirebaseSwiftUIExampleTests {
25
24
return AuthService ( configuration: resolvedConfiguration)
26
25
}
27
26
27
+ func createEmail( ) -> String {
28
+ let before = UUID ( ) . uuidString. prefix ( 8 )
29
+ let after = UUID ( ) . uuidString. prefix ( 6 )
30
+ return " \( before) @ \( after) .com "
31
+ }
32
+
28
33
@Test
29
34
@MainActor
30
35
func testCreateEmailPasswordUser( ) async throws {
@@ -35,7 +40,7 @@ struct FirebaseSwiftUIExampleTests {
35
40
#expect( service. errorMessage. isEmpty)
36
41
#expect( service. signedInCredential == nil )
37
42
#expect( service. currentUser == nil )
38
- try await service. createUser ( withEmail: kEmailAddress , password: kPassword)
43
+ try await service. createUser ( withEmail: createEmail ( ) , password: kPassword)
39
44
40
45
#expect( service. authenticationState == . authenticated)
41
46
#expect( service. authView == . authPicker)
@@ -49,22 +54,23 @@ struct FirebaseSwiftUIExampleTests {
49
54
@MainActor
50
55
func testSignInUser( ) async throws {
51
56
let service = try await prepareFreshAuthService ( )
52
- // TODO: - it clears emulator data but seems like it is still there?
53
- // try await service.createUser(withEmail: kEmailAddress, password: kPassword)
54
- // try await service.signOut()
57
+ let email = createEmail ( )
58
+ try await service. createUser ( withEmail: email, password: kPassword)
59
+ try await service. signOut ( )
60
+ try await Task . sleep ( nanoseconds: 1_000_000_000 )
55
61
#expect( service. authenticationState == . unauthenticated)
56
62
#expect( service. authView == . authPicker)
57
63
#expect( service. errorMessage. isEmpty)
58
64
#expect( service. signedInCredential == nil )
59
65
#expect( service. currentUser == nil )
60
66
61
- try await service. signIn ( withEmail: kEmailAddress , password: kPassword)
67
+ try await service. signIn ( withEmail: email , password: kPassword)
62
68
63
69
#expect( service. authenticationState == . authenticated)
64
70
#expect( service. authView == . authPicker)
65
71
#expect( service. errorMessage. isEmpty)
66
72
#expect( service. currentUser != nil )
67
73
// TODO: - reinstate once this PR is merged: https://github.com/firebase/FirebaseUI-iOS/pull/1256
68
- // #expect(service.signedInCredential is AuthCredential)
74
+ // #expect(service.signedInCredential is AuthCredential)
69
75
}
70
76
}
0 commit comments