Skip to content

Commit 24bba0a

Browse files
committed
One more rebase
1 parent 30320fe commit 24bba0a

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

packages-exp/auth-exp/src/core/providers/anonymous.test.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,19 @@
1818
import { ProviderId, SignInMethod } from '@firebase/auth-types-exp';
1919
import { expect, use } from 'chai';
2020
import * as chaiAsPromised from 'chai-as-promised';
21+
import { testAuth } from '../../../test/mock_auth';
22+
import { Auth } from '../../model/auth';
2123
import { AnonymousCredential, AnonymousProvider } from './anonymous';
22-
import { mockAuth } from '../../../test/mock_auth';
2324

2425
use(chaiAsPromised);
2526

2627
describe('core/providers/anonymous', () => {
28+
let auth: Auth;
29+
30+
beforeEach(async () => {
31+
auth = await testAuth();
32+
});
33+
2734
describe('AnonymousCredential', () => {
2835
const credential = new AnonymousCredential();
2936

@@ -44,23 +51,23 @@ describe('core/providers/anonymous', () => {
4451
describe('#_getIdTokenResponse', () => {
4552
it('throws', async () => {
4653
await expect(
47-
credential._getIdTokenResponse(mockAuth)
54+
credential._getIdTokenResponse(auth)
4855
).to.be.rejectedWith(Error);
4956
});
5057
});
5158

5259
describe('#_linkToIdToken', () => {
5360
it('throws', async () => {
5461
await expect(
55-
credential._linkToIdToken(mockAuth, 'id-token')
62+
credential._linkToIdToken(auth, 'id-token')
5663
).to.be.rejectedWith(Error);
5764
});
5865
});
5966

6067
describe('#_matchIdTokenWithUid', () => {
6168
it('throws', () => {
6269
expect(() =>
63-
credential._matchIdTokenWithUid(mockAuth, 'other-uid')
70+
credential._matchIdTokenWithUid(auth, 'other-uid')
6471
).to.throw(Error);
6572
});
6673
});

packages-exp/auth-exp/src/core/strategies/anonymous.test.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,21 @@ import {
2222
} from '@firebase/auth-types-exp';
2323
import { expect } from 'chai';
2424
import { mockEndpoint } from '../../../test/api/helper';
25-
import { mockAuth, testUser } from '../../../test/mock_auth';
25+
import { testAuth, testUser } from '../../../test/mock_auth';
2626
import * as mockFetch from '../../../test/mock_fetch';
2727
import { Endpoint } from '../../api';
2828
import { APIUserInfo } from '../../api/account_management/account';
29+
import { Auth } from '../../model/auth';
2930
import { signInAnonymously } from './anonymous';
3031

3132
describe('core/strategies/anonymous', () => {
33+
let auth: Auth;
3234
const serverUser: APIUserInfo = {
3335
localId: 'local-id'
3436
};
35-
36-
beforeEach(() => {
37+
38+
beforeEach(async () => {
39+
auth = await testAuth();
3740
mockFetch.setUp();
3841
mockEndpoint(Endpoint.SIGN_UP, {
3942
idToken: 'id-token',
@@ -50,7 +53,7 @@ describe('core/strategies/anonymous', () => {
5053
describe('signInAnonymously', () => {
5154
it('should sign in an anonymous user', async () => {
5255
const { credential, user, operationType } = await signInAnonymously(
53-
mockAuth
56+
auth
5457
);
5558
expect(credential?.providerId).to.eq(ProviderId.ANONYMOUS);
5659
expect(credential?.signInMethod).to.eq(SignInMethod.ANONYMOUS);
@@ -61,11 +64,11 @@ describe('core/strategies/anonymous', () => {
6164

6265
context('already signed in anonymously', () => {
6366
it('should return the current user', async () => {
64-
const userCredential = await signInAnonymously(mockAuth);
67+
const userCredential = await signInAnonymously(auth);
6568
expect(userCredential.user.isAnonymous).to.be.true;
6669

6770
const { credential, user, operationType } = await signInAnonymously(
68-
mockAuth
71+
auth
6972
);
7073
expect(credential?.providerId).to.eq(ProviderId.ANONYMOUS);
7174
expect(credential?.signInMethod).to.eq(SignInMethod.ANONYMOUS);
@@ -77,12 +80,12 @@ describe('core/strategies/anonymous', () => {
7780

7881
context('already signed in with a non-anonymous account', () => {
7982
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);
8285
expect(fakeUser.isAnonymous).to.be.false;
8386

8487
const { credential, user, operationType } = await signInAnonymously(
85-
mockAuth
88+
auth
8689
);
8790
expect(credential?.providerId).to.eq(ProviderId.ANONYMOUS);
8891
expect(credential?.signInMethod).to.eq(SignInMethod.ANONYMOUS);

0 commit comments

Comments
 (0)