@@ -24,10 +24,9 @@ import { ProviderId, UserInfo } from '@firebase/auth-types-exp';
24
24
25
25
// import { UserInfo } from '@firebase/auth-types-exp';
26
26
import { mockEndpoint } from '../../../test/api/helper' ;
27
- import { testPersistence , testUser } from '../../../test/mock_auth' ;
27
+ import { TestAuth , testAuth , testUser } from '../../../test/mock_auth' ;
28
28
import * as fetch from '../../../test/mock_fetch' ;
29
29
import { Endpoint } from '../../api' ;
30
- import { Auth } from '../../model/auth' ;
31
30
import { User } from '../../model/user' ;
32
31
import { updateEmail , updatePassword , updateProfile } from './account_info' ;
33
32
@@ -45,9 +44,11 @@ const PASSWORD_PROVIDER: UserInfo = {
45
44
46
45
describe ( 'core/user/profile' , ( ) => {
47
46
let user : User ;
47
+ let auth : TestAuth ;
48
48
49
- beforeEach ( ( ) => {
50
- user = testUser ( 'uid' , '' , true ) ;
49
+ beforeEach ( async ( ) => {
50
+ auth = await testAuth ( ) ;
51
+ user = testUser ( auth , 'uid' , '' , true ) ;
51
52
fetch . setUp ( ) ;
52
53
} ) ;
53
54
@@ -134,11 +135,9 @@ describe('core/user/profile', () => {
134
135
} ) ;
135
136
136
137
describe ( 'notifications' , ( ) => {
137
- let auth : Auth ;
138
138
let idTokenChange : sinon . SinonStub ;
139
139
140
140
beforeEach ( async ( ) => {
141
- auth = user . auth ;
142
141
idTokenChange = sinon . stub ( ) ;
143
142
auth . onIdTokenChanged ( idTokenChange ) ;
144
143
@@ -158,7 +157,7 @@ describe('core/user/profile', () => {
158
157
159
158
await updateProfile ( user , { displayName : 'd' } ) ;
160
159
expect ( idTokenChange ) . to . have . been . called ;
161
- expect ( testPersistence . lastPersistedBlob ) . to . eql ( user . toPlainObject ( ) ) ;
160
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
162
161
} ) ;
163
162
164
163
it ( 'does NOT trigger a token update if unnecessary' , async ( ) => {
@@ -170,7 +169,7 @@ describe('core/user/profile', () => {
170
169
171
170
await updateProfile ( user , { displayName : 'd' } ) ;
172
171
expect ( idTokenChange ) . not . to . have . been . called ;
173
- expect ( testPersistence . lastPersistedBlob ) . to . eql ( user . toPlainObject ( ) ) ;
172
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
174
173
} ) ;
175
174
} ) ;
176
175
@@ -190,7 +189,7 @@ describe('core/user/profile', () => {
190
189
191
190
await updatePassword ( user , '[email protected] ' ) ;
192
191
expect ( idTokenChange ) . to . have . been . called ;
193
- expect ( testPersistence . lastPersistedBlob ) . to . eql ( user . toPlainObject ( ) ) ;
192
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
194
193
} ) ;
195
194
196
195
it ( 'does NOT trigger a token update if unnecessary' , async ( ) => {
@@ -202,7 +201,7 @@ describe('core/user/profile', () => {
202
201
203
202
await updateEmail ( user , '[email protected] ' ) ;
204
203
expect ( idTokenChange ) . not . to . have . been . called ;
205
- expect ( testPersistence . lastPersistedBlob ) . to . eql ( user . toPlainObject ( ) ) ;
204
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
206
205
} ) ;
207
206
} ) ;
208
207
@@ -222,7 +221,7 @@ describe('core/user/profile', () => {
222
221
223
222
await updatePassword ( user , 'pass' ) ;
224
223
expect ( idTokenChange ) . to . have . been . called ;
225
- expect ( testPersistence . lastPersistedBlob ) . to . eql ( user . toPlainObject ( ) ) ;
224
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
226
225
} ) ;
227
226
228
227
it ( 'does NOT trigger a token update if unnecessary' , async ( ) => {
@@ -234,7 +233,7 @@ describe('core/user/profile', () => {
234
233
235
234
await updatePassword ( user , 'pass' ) ;
236
235
expect ( idTokenChange ) . not . to . have . been . called ;
237
- expect ( testPersistence . lastPersistedBlob ) . to . eql ( user . toPlainObject ( ) ) ;
236
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
238
237
} ) ;
239
238
} ) ;
240
239
} ) ;
0 commit comments