Skip to content

Commit 33984f1

Browse files
committed
PR feedback
1 parent 93af87f commit 33984f1

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

packages-exp/auth-exp/test/integration/flows/anonymous.test.ts

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,13 @@ import { expect, use } from 'chai';
1919
import * as chaiAsPromised from 'chai-as-promised';
2020

2121
import {
22-
createUserWithEmailAndPassword,
23-
EmailAuthProvider,
24-
linkWithCredential,
25-
signInAnonymously,
26-
signInWithEmailAndPassword,
27-
updateEmail,
28-
updatePassword
22+
createUserWithEmailAndPassword, EmailAuthProvider, linkWithCredential, signInAnonymously,
23+
signInWithEmailAndPassword, updateEmail, updatePassword
2924
} from '@firebase/auth-exp/index.browser';
3025
import { OperationType } from '@firebase/auth-types-exp';
3126
import { FirebaseError } from '@firebase/util';
3227

33-
import {
34-
initIntegrationTestContext,
35-
randomEmail
36-
} from '../../helpers/integration/helpers';
28+
import { initIntegrationTestContext, randomEmail } from '../../helpers/integration/helpers';
3729

3830
use(chaiAsPromised);
3931

@@ -47,7 +39,7 @@ describe('Integration test: anonymous auth', () => {
4739

4840
const user = userCred.user;
4941
expect(user.isAnonymous).to.be.true;
50-
expect(typeof user.uid).to.eq('string');
42+
expect(user.uid).to.be.a('string');
5143
});
5244

5345
it('second sign in on the same device yields same user', async () => {
@@ -85,27 +77,28 @@ describe('Integration test: anonymous auth', () => {
8577
});
8678

8779
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');
9183

92-
const anonId = user.uid;
9384
await auth.signOut();
85+
86+
const {user: emailPassUser} = await signInWithEmailAndPassword(auth, email, 'password');
9487
expect(
95-
(await signInWithEmailAndPassword(auth, email, 'password')).user.uid
96-
).to.eq(anonId);
88+
emailPassUser.uid
89+
).to.eq(anonUser.uid);
9790
});
9891

9992
it('account can be linked using email and password', async () => {
100-
const { user } = await signInAnonymously(auth);
93+
const { user: anonUser } = await signInAnonymously(auth);
10194
const cred = EmailAuthProvider.credential(email, 'password');
102-
const id = user.uid;
103-
await linkWithCredential(user, cred);
95+
await linkWithCredential(anonUser, cred);
10496
await auth.signOut();
10597

98+
const {user: emailPassUser} = await signInWithEmailAndPassword(auth, email, 'password');
10699
expect(
107-
(await signInWithEmailAndPassword(auth, email, 'password')).user.uid
108-
).to.eq(id);
100+
emailPassUser.uid
101+
).to.eq(anonUser.uid);
109102
});
110103

111104
it('account cannot be linked with existing email/password', async () => {

0 commit comments

Comments
 (0)