@@ -19,21 +19,13 @@ import { expect, use } from 'chai';
19
19
import * as chaiAsPromised from 'chai-as-promised' ;
20
20
21
21
import {
22
- createUserWithEmailAndPassword ,
23
- EmailAuthProvider ,
24
- linkWithCredential ,
25
- signInAnonymously ,
26
- signInWithEmailAndPassword ,
27
- updateEmail ,
28
- updatePassword
22
+ createUserWithEmailAndPassword , EmailAuthProvider , linkWithCredential , signInAnonymously ,
23
+ signInWithEmailAndPassword , updateEmail , updatePassword
29
24
} from '@firebase/auth-exp/index.browser' ;
30
25
import { OperationType } from '@firebase/auth-types-exp' ;
31
26
import { FirebaseError } from '@firebase/util' ;
32
27
33
- import {
34
- initIntegrationTestContext ,
35
- randomEmail
36
- } from '../../helpers/integration/helpers' ;
28
+ import { initIntegrationTestContext , randomEmail } from '../../helpers/integration/helpers' ;
37
29
38
30
use ( chaiAsPromised ) ;
39
31
@@ -47,7 +39,7 @@ describe('Integration test: anonymous auth', () => {
47
39
48
40
const user = userCred . user ;
49
41
expect ( user . isAnonymous ) . to . be . true ;
50
- expect ( typeof user . uid ) . to . eq ( 'string' ) ;
42
+ expect ( user . uid ) . to . be . a ( 'string' ) ;
51
43
} ) ;
52
44
53
45
it ( 'second sign in on the same device yields same user' , async ( ) => {
@@ -85,27 +77,28 @@ describe('Integration test: anonymous auth', () => {
85
77
} ) ;
86
78
87
79
it ( 'account can be upgraded by setting email and password' , async ( ) => {
88
- const { user } = await signInAnonymously ( auth ) ;
89
- await updateEmail ( user , email ) ;
90
- await updatePassword ( user , 'password' ) ;
80
+ const { user : anonUser } = await signInAnonymously ( auth ) ;
81
+ await updateEmail ( anonUser , email ) ;
82
+ await updatePassword ( anonUser , 'password' ) ;
91
83
92
- const anonId = user . uid ;
93
84
await auth . signOut ( ) ;
85
+
86
+ const { user : emailPassUser } = await signInWithEmailAndPassword ( auth , email , 'password' ) ;
94
87
expect (
95
- ( await signInWithEmailAndPassword ( auth , email , 'password' ) ) . user . uid
96
- ) . to . eq ( anonId ) ;
88
+ emailPassUser . uid
89
+ ) . to . eq ( anonUser . uid ) ;
97
90
} ) ;
98
91
99
92
it ( 'account can be linked using email and password' , async ( ) => {
100
- const { user } = await signInAnonymously ( auth ) ;
93
+ const { user : anonUser } = await signInAnonymously ( auth ) ;
101
94
const cred = EmailAuthProvider . credential ( email , 'password' ) ;
102
- const id = user . uid ;
103
- await linkWithCredential ( user , cred ) ;
95
+ await linkWithCredential ( anonUser , cred ) ;
104
96
await auth . signOut ( ) ;
105
97
98
+ const { user : emailPassUser } = await signInWithEmailAndPassword ( auth , email , 'password' ) ;
106
99
expect (
107
- ( await signInWithEmailAndPassword ( auth , email , 'password' ) ) . user . uid
108
- ) . to . eq ( id ) ;
100
+ emailPassUser . uid
101
+ ) . to . eq ( anonUser . uid ) ;
109
102
} ) ;
110
103
111
104
it ( 'account cannot be linked with existing email/password' , async ( ) => {
0 commit comments