@@ -22,18 +22,21 @@ import {
22
22
} from '@firebase/auth-types-exp' ;
23
23
import { expect } from 'chai' ;
24
24
import { mockEndpoint } from '../../../test/api/helper' ;
25
- import { mockAuth , testUser } from '../../../test/mock_auth' ;
25
+ import { testAuth , testUser } from '../../../test/mock_auth' ;
26
26
import * as mockFetch from '../../../test/mock_fetch' ;
27
27
import { Endpoint } from '../../api' ;
28
28
import { APIUserInfo } from '../../api/account_management/account' ;
29
+ import { Auth } from '../../model/auth' ;
29
30
import { signInAnonymously } from './anonymous' ;
30
31
31
32
describe ( 'core/strategies/anonymous' , ( ) => {
33
+ let auth : Auth ;
32
34
const serverUser : APIUserInfo = {
33
35
localId : 'local-id'
34
36
} ;
35
-
36
- beforeEach ( ( ) => {
37
+
38
+ beforeEach ( async ( ) => {
39
+ auth = await testAuth ( ) ;
37
40
mockFetch . setUp ( ) ;
38
41
mockEndpoint ( Endpoint . SIGN_UP , {
39
42
idToken : 'id-token' ,
@@ -50,7 +53,7 @@ describe('core/strategies/anonymous', () => {
50
53
describe ( 'signInAnonymously' , ( ) => {
51
54
it ( 'should sign in an anonymous user' , async ( ) => {
52
55
const { credential, user, operationType } = await signInAnonymously (
53
- mockAuth
56
+ auth
54
57
) ;
55
58
expect ( credential ?. providerId ) . to . eq ( ProviderId . ANONYMOUS ) ;
56
59
expect ( credential ?. signInMethod ) . to . eq ( SignInMethod . ANONYMOUS ) ;
@@ -61,11 +64,11 @@ describe('core/strategies/anonymous', () => {
61
64
62
65
context ( 'already signed in anonymously' , ( ) => {
63
66
it ( 'should return the current user' , async ( ) => {
64
- const userCredential = await signInAnonymously ( mockAuth ) ;
67
+ const userCredential = await signInAnonymously ( auth ) ;
65
68
expect ( userCredential . user . isAnonymous ) . to . be . true ;
66
69
67
70
const { credential, user, operationType } = await signInAnonymously (
68
- mockAuth
71
+ auth
69
72
) ;
70
73
expect ( credential ?. providerId ) . to . eq ( ProviderId . ANONYMOUS ) ;
71
74
expect ( credential ?. signInMethod ) . to . eq ( SignInMethod . ANONYMOUS ) ;
@@ -77,12 +80,12 @@ describe('core/strategies/anonymous', () => {
77
80
78
81
context ( 'already signed in with a non-anonymous account' , ( ) => {
79
82
it ( 'should sign in as a new user user' , async ( ) => {
80
- const fakeUser = testUser ( 'other-uid' ) ;
81
- await mockAuth . updateCurrentUser ( fakeUser ) ;
83
+ const fakeUser = testUser ( auth , 'other-uid' ) ;
84
+ await auth . updateCurrentUser ( fakeUser ) ;
82
85
expect ( fakeUser . isAnonymous ) . to . be . false ;
83
86
84
87
const { credential, user, operationType } = await signInAnonymously (
85
- mockAuth
88
+ auth
86
89
) ;
87
90
expect ( credential ?. providerId ) . to . eq ( ProviderId . ANONYMOUS ) ;
88
91
expect ( credential ?. signInMethod ) . to . eq ( SignInMethod . ANONYMOUS ) ;
0 commit comments