Skip to content

Commit 1918a18

Browse files
committed
Update tests further
1 parent 5645660 commit 1918a18

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

packages-exp/auth-exp/src/core/user/account_info.test.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ import { ProviderId, UserInfo } from '@firebase/auth-types-exp';
2424

2525
// import { UserInfo } from '@firebase/auth-types-exp';
2626
import { mockEndpoint } from '../../../test/api/helper';
27-
import { testPersistence, testUser } from '../../../test/mock_auth';
27+
import { TestAuth, testAuth, testUser } from '../../../test/mock_auth';
2828
import * as fetch from '../../../test/mock_fetch';
2929
import { Endpoint } from '../../api';
30-
import { Auth } from '../../model/auth';
3130
import { User } from '../../model/user';
3231
import { updateEmail, updatePassword, updateProfile } from './account_info';
3332

@@ -45,9 +44,11 @@ const PASSWORD_PROVIDER: UserInfo = {
4544

4645
describe('core/user/profile', () => {
4746
let user: User;
47+
let auth: TestAuth;
4848

49-
beforeEach(() => {
50-
user = testUser('uid', '', true);
49+
beforeEach(async () => {
50+
auth = await testAuth();
51+
user = testUser(auth, 'uid', '', true);
5152
fetch.setUp();
5253
});
5354

@@ -134,11 +135,9 @@ describe('core/user/profile', () => {
134135
});
135136

136137
describe('notifications', () => {
137-
let auth: Auth;
138138
let idTokenChange: sinon.SinonStub;
139139

140140
beforeEach(async () => {
141-
auth = user.auth;
142141
idTokenChange = sinon.stub();
143142
auth.onIdTokenChanged(idTokenChange);
144143

@@ -158,7 +157,7 @@ describe('core/user/profile', () => {
158157

159158
await updateProfile(user, {displayName: 'd'});
160159
expect(idTokenChange).to.have.been.called;
161-
expect(testPersistence.lastPersistedBlob).to.eql(user.toPlainObject());
160+
expect(auth.persistenceLayer.lastObjectSet).to.eql(user.toPlainObject());
162161
});
163162

164163
it('does NOT trigger a token update if unnecessary', async () => {
@@ -170,7 +169,7 @@ describe('core/user/profile', () => {
170169

171170
await updateProfile(user, {displayName: 'd'});
172171
expect(idTokenChange).not.to.have.been.called;
173-
expect(testPersistence.lastPersistedBlob).to.eql(user.toPlainObject());
172+
expect(auth.persistenceLayer.lastObjectSet).to.eql(user.toPlainObject());
174173
});
175174
});
176175

@@ -190,7 +189,7 @@ describe('core/user/profile', () => {
190189

191190
await updatePassword(user, '[email protected]');
192191
expect(idTokenChange).to.have.been.called;
193-
expect(testPersistence.lastPersistedBlob).to.eql(user.toPlainObject());
192+
expect(auth.persistenceLayer.lastObjectSet).to.eql(user.toPlainObject());
194193
});
195194

196195
it('does NOT trigger a token update if unnecessary', async () => {
@@ -202,7 +201,7 @@ describe('core/user/profile', () => {
202201

203202
await updateEmail(user, '[email protected]');
204203
expect(idTokenChange).not.to.have.been.called;
205-
expect(testPersistence.lastPersistedBlob).to.eql(user.toPlainObject());
204+
expect(auth.persistenceLayer.lastObjectSet).to.eql(user.toPlainObject());
206205
});
207206
});
208207

@@ -222,7 +221,7 @@ describe('core/user/profile', () => {
222221

223222
await updatePassword(user, 'pass');
224223
expect(idTokenChange).to.have.been.called;
225-
expect(testPersistence.lastPersistedBlob).to.eql(user.toPlainObject());
224+
expect(auth.persistenceLayer.lastObjectSet).to.eql(user.toPlainObject());
226225
});
227226

228227
it('does NOT trigger a token update if unnecessary', async () => {
@@ -234,7 +233,7 @@ describe('core/user/profile', () => {
234233

235234
await updatePassword(user, 'pass');
236235
expect(idTokenChange).not.to.have.been.called;
237-
expect(testPersistence.lastPersistedBlob).to.eql(user.toPlainObject());
236+
expect(auth.persistenceLayer.lastObjectSet).to.eql(user.toPlainObject());
238237
});
239238
});
240239
});

0 commit comments

Comments
 (0)