Skip to content

Commit 3a0c2b9

Browse files
committed
Formatting
1 parent 2cb67d3 commit 3a0c2b9

File tree

3 files changed

+74
-19
lines changed

3 files changed

+74
-19
lines changed

packages-exp/auth-exp/karma.conf.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function getTestFiles(argv) {
3636
if (argv.unit) {
3737
return ['src/**/*.test.ts', 'test/helpers/**/*.test.ts'];
3838
} else if (argv.integration) {
39-
return argv.local ? ['test/integration/**/*.test.ts'] : ['test/integration/**/*!(local).test.ts'];
39+
return argv.local
40+
? ['test/integration/**/*.test.ts']
41+
: ['test/integration/**/*!(local).test.ts'];
4042
} else if (argv.cordova) {
4143
return ['src/platform_cordova/**/*.test.ts'];
4244
} else {

packages-exp/auth-exp/test/helpers/integration/helpers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ export async function cleanUpTestInstance(auth: Auth): Promise<void> {
7575
function stubConsoleToSilenceEmulatorWarnings(): sinon.SinonStub {
7676
const originalConsoleInfo = console.info.bind(console);
7777
return sinon.stub(console, 'info').callsFake((...args: unknown[]) => {
78-
if (!JSON.stringify(args[0]).includes('WARNING: You are using the Auth Emulator')) {
78+
if (
79+
!JSON.stringify(args[0]).includes(
80+
'WARNING: You are using the Auth Emulator'
81+
)
82+
) {
7983
originalConsoleInfo(...args);
8084
}
8185
});

packages-exp/auth-exp/test/integration/flows/custom.local.test.ts

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
1-
import {Auth, createUserWithEmailAndPassword, EmailAuthProvider, linkWithCredential, OperationType, signInAnonymously, signInWithCustomToken, signInWithEmailAndPassword, updateEmail, updatePassword} from '@firebase/auth-exp';
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import {
19+
Auth,
20+
createUserWithEmailAndPassword,
21+
EmailAuthProvider,
22+
linkWithCredential,
23+
OperationType,
24+
signInAnonymously,
25+
signInWithCustomToken,
26+
signInWithEmailAndPassword,
27+
updateEmail,
28+
updatePassword
29+
} from '@firebase/auth-exp';
230
import { FirebaseError } from '@firebase/util';
331
import { expect, use } from 'chai';
432
import * as chaiAsPromised from 'chai-as-promised';
5-
import { cleanUpTestInstance, getTestInstance, randomEmail } from '../../helpers/integration/helpers';
33+
import {
34+
cleanUpTestInstance,
35+
getTestInstance,
36+
randomEmail
37+
} from '../../helpers/integration/helpers';
638

739
use(chaiAsPromised);
840

@@ -22,25 +54,33 @@ describe('Integration test: custom auth', () => {
2254
});
2355

2456
it('signs in with custom token', async () => {
25-
const cred = await signInWithCustomToken(auth, JSON.stringify({
26-
uid: 'custom-uid-yay',
27-
claims: {customClaim: 'some-claim'},
28-
}));
57+
const cred = await signInWithCustomToken(
58+
auth,
59+
JSON.stringify({
60+
uid: 'custom-uid-yay',
61+
claims: { customClaim: 'some-claim' }
62+
})
63+
);
2964
expect(auth.currentUser).to.eq(cred.user);
3065
expect(cred.operationType).to.eq(OperationType.SIGN_IN);
3166

32-
const {user} = cred;
67+
const { user } = cred;
3368
expect(user.isAnonymous).to.be.false;
3469
expect(user.uid).to.eq('custom-uid-yay');
35-
expect((await user.getIdTokenResult(false)).claims.customClaim).to.eq('some-claim');
70+
expect((await user.getIdTokenResult(false)).claims.customClaim).to.eq(
71+
'some-claim'
72+
);
3673
expect(user.providerId).to.eq('firebase');
3774
});
3875

3976
it('uid will overwrite existing user, joining accounts', async () => {
40-
const {user: anonUser} = await signInAnonymously(auth);
41-
const customCred = await signInWithCustomToken(auth, JSON.stringify({
42-
uid: anonUser.uid,
43-
}));
77+
const { user: anonUser } = await signInAnonymously(auth);
78+
const customCred = await signInWithCustomToken(
79+
auth,
80+
JSON.stringify({
81+
uid: anonUser.uid
82+
})
83+
);
4484

4585
expect(auth.currentUser).to.eq(customCred.user);
4686
expect(customCred.user.uid).to.eq(anonUser.uid);
@@ -54,7 +94,7 @@ describe('Integration test: custom auth', () => {
5494
beforeEach(() => {
5595
email = randomEmail();
5696
customToken = JSON.stringify({
57-
uid: email,
97+
uid: email
5898
});
5999
});
60100

@@ -79,7 +119,10 @@ describe('Integration test: custom auth', () => {
79119
});
80120

81121
it('account can have email / password attached', async () => {
82-
const { user: customUser } = await signInWithCustomToken(auth, customToken);
122+
const { user: customUser } = await signInWithCustomToken(
123+
auth,
124+
customToken
125+
);
83126
await updateEmail(customUser, email);
84127
await updatePassword(customUser, 'password');
85128

@@ -94,7 +137,10 @@ describe('Integration test: custom auth', () => {
94137
});
95138

96139
it('account can be linked using email and password', async () => {
97-
const { user: customUser } = await signInWithCustomToken(auth, customToken);
140+
const { user: customUser } = await signInWithCustomToken(
141+
auth,
142+
customToken
143+
);
98144
const cred = EmailAuthProvider.credential(email, 'password');
99145
await linkWithCredential(customUser, cred);
100146
await auth.signOut();
@@ -109,12 +155,15 @@ describe('Integration test: custom auth', () => {
109155

110156
it('account cannot be linked with existing email/password', async () => {
111157
await createUserWithEmailAndPassword(auth, email, 'password');
112-
const { user: customUser } = await signInWithCustomToken(auth, customToken);
158+
const { user: customUser } = await signInWithCustomToken(
159+
auth,
160+
customToken
161+
);
113162
const cred = EmailAuthProvider.credential(email, 'password');
114163
await expect(linkWithCredential(customUser, cred)).to.be.rejectedWith(
115164
FirebaseError,
116165
'auth/email-already-in-use'
117166
);
118167
});
119168
});
120-
});
169+
});

0 commit comments

Comments
 (0)