Skip to content

Commit 56904cb

Browse files
committed
Formatting, license
1 parent 87c6245 commit 56904cb

File tree

5 files changed

+74
-33
lines changed

5 files changed

+74
-33
lines changed

packages-exp/auth-compat-exp/index.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,26 @@ import {
2424
InstantiationMode
2525
} from '@firebase/component';
2626

27-
import { EmailAuthProvider, EmailAuthProvider_Instance, FacebookAuthProvider, FacebookAuthProvider_Instance, FirebaseAuth, GithubAuthProvider, GithubAuthProvider_Instance, GoogleAuthProvider, GoogleAuthProvider_Instance, OAuthProvider, PhoneAuthProvider, PhoneAuthProvider_Instance, PhoneMultiFactorGenerator, RecaptchaVerifier, RecaptchaVerifier_Instance, SAMLAuthProvider, TwitterAuthProvider, TwitterAuthProvider_Instance } from '@firebase/auth-types';
27+
import {
28+
EmailAuthProvider,
29+
EmailAuthProvider_Instance,
30+
FacebookAuthProvider,
31+
FacebookAuthProvider_Instance,
32+
FirebaseAuth,
33+
GithubAuthProvider,
34+
GithubAuthProvider_Instance,
35+
GoogleAuthProvider,
36+
GoogleAuthProvider_Instance,
37+
OAuthProvider,
38+
PhoneAuthProvider,
39+
PhoneAuthProvider_Instance,
40+
PhoneMultiFactorGenerator,
41+
RecaptchaVerifier,
42+
RecaptchaVerifier_Instance,
43+
SAMLAuthProvider,
44+
TwitterAuthProvider,
45+
TwitterAuthProvider_Instance
46+
} from '@firebase/auth-types';
2847
import { version } from './package.json';
2948
import { Auth } from './src/auth';
3049
import { Persistence } from './src/persistence';

packages-exp/auth-compat-exp/scripts/run_node_tests.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ const mocha = resolve(__dirname, '../../../node_modules/.bin/mocha');
3434

3535
process.env.TS_NODE_COMPILER_OPTIONS = '{"module":"commonjs", "target": "es6"}';
3636

37-
let testConfig = [
38-
'src/**/*.test.ts',
39-
];
37+
let testConfig = ['src/**/*.test.ts'];
4038

4139
if (argv.integration) {
4240
testConfig = ['test/integration/flows/**.test.ts'];

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
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+
118
import * as sinon from 'sinon';
219
import firebase from '@firebase/app-compat';
320
import * as exp from '@firebase/auth-exp/internal';
4-
import { getAppConfig, getEmulatorUrl } from '../../../auth-exp/test/helpers/integration/settings';
21+
import {
22+
getAppConfig,
23+
getEmulatorUrl
24+
} from '../../../auth-exp/test/helpers/integration/settings';
525
import { resetEmulator } from '../../../auth-exp/test/helpers/integration/emulator_rest_helpers';
626

727
export function initializeTestInstance(): void {

packages-exp/auth-compat-exp/test/integration/flows/anonymous.test.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
import { expect, use } from 'chai';
1919
import * as chaiAsPromised from 'chai-as-promised';
2020

21-
2221
import firebase from '@firebase/app-compat';
2322
import '@firebase/auth-compat';
2423
import { FirebaseError } from '@firebase/util';
25-
import { cleanUpTestInstance, initializeTestInstance, randomEmail } from '../../helpers/helpers';
24+
import {
25+
cleanUpTestInstance,
26+
initializeTestInstance,
27+
randomEmail
28+
} from '../../helpers/helpers';
2629

2730
use(chaiAsPromised);
2831

@@ -61,18 +64,16 @@ describe('Integration test: anonymous auth', () => {
6164

6265
it('anonymous / email-password accounts remain independent', async () => {
6366
let anonCred = await firebase.auth().signInAnonymously();
64-
const emailCred = await firebase.auth().createUserWithEmailAndPassword(
65-
email,
66-
'password'
67-
);
67+
const emailCred = await firebase
68+
.auth()
69+
.createUserWithEmailAndPassword(email, 'password');
6870
expect(emailCred.user!.uid).not.to.eql(anonCred.user!.uid);
6971

7072
await firebase.auth().signOut();
7173
anonCred = await firebase.auth().signInAnonymously();
72-
const emailSignIn = await firebase.auth().signInWithEmailAndPassword(
73-
email,
74-
'password'
75-
);
74+
const emailSignIn = await firebase
75+
.auth()
76+
.signInWithEmailAndPassword(email, 'password');
7677
expect(emailCred.user!.uid).to.eql(emailSignIn.user!.uid);
7778
expect(emailSignIn.user!.uid).not.to.eql(anonCred.user!.uid);
7879
});
@@ -84,30 +85,34 @@ describe('Integration test: anonymous auth', () => {
8485

8586
await firebase.auth().signOut();
8687

87-
const { user: emailPassUser } = await firebase.auth().signInWithEmailAndPassword(
88-
email,
89-
'password'
90-
);
88+
const {
89+
user: emailPassUser
90+
} = await firebase.auth().signInWithEmailAndPassword(email, 'password');
9191
expect(emailPassUser!.uid).to.eq(anonUser!.uid);
9292
});
9393

9494
it('account can be linked using email and password', async () => {
9595
const { user: anonUser } = await firebase.auth().signInAnonymously();
96-
const cred = firebase.auth.EmailAuthProvider.credential(email, 'password');
97-
await anonUser!.linkWithCredential(cred);
98-
await firebase.auth().signOut();
99-
100-
const { user: emailPassUser } = await firebase.auth().signInWithEmailAndPassword(
96+
const cred = firebase.auth.EmailAuthProvider.credential(
10197
email,
10298
'password'
10399
);
100+
await anonUser!.linkWithCredential(cred);
101+
await firebase.auth().signOut();
102+
103+
const {
104+
user: emailPassUser
105+
} = await firebase.auth().signInWithEmailAndPassword(email, 'password');
104106
expect(emailPassUser!.uid).to.eq(anonUser!.uid);
105107
});
106108

107109
it('account cannot be linked with existing email/password', async () => {
108110
await firebase.auth().createUserWithEmailAndPassword(email, 'password');
109111
const { user: anonUser } = await firebase.auth().signInAnonymously();
110-
const cred = firebase.auth.EmailAuthProvider.credential(email, 'password');
112+
const cred = firebase.auth.EmailAuthProvider.credential(
113+
email,
114+
'password'
115+
);
111116
await expect(anonUser!.linkWithCredential(cred)).to.be.rejectedWith(
112117
FirebaseError,
113118
'auth/email-already-in-use'

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ export async function getPhoneVerificationCodes(): Promise<
4343
Record<string, VerificationSession>
4444
> {
4545
const url = buildEmulatorUrlForPath('verificationCodes');
46-
const response: VerificationCodesResponse = await (
47-
await doFetch(url)
48-
).json();
46+
const response: VerificationCodesResponse = await (await doFetch(url)).json();
4947

5048
return response.verificationCodes.reduce((accum, session) => {
5149
accum[session.sessionInfo] = session;
@@ -55,9 +53,7 @@ export async function getPhoneVerificationCodes(): Promise<
5553

5654
export async function getOobCodes(): Promise<OobCodeSession[]> {
5755
const url = buildEmulatorUrlForPath('oobCodes');
58-
const response: OobCodesResponse = await (
59-
await doFetch(url)
60-
).json();
56+
const response: OobCodesResponse = await (await doFetch(url)).json();
6157
return response.oobCodes;
6258
}
6359

@@ -77,5 +73,8 @@ function doFetch(url: string, request?: RequestInit): ReturnType<typeof fetch> {
7773
return fetch(url, request);
7874
}
7975

80-
return fetchImpl.default(url, request as fetchImpl.RequestInit) as unknown as ReturnType<typeof fetch>;
81-
}
76+
return (fetchImpl.default(
77+
url,
78+
request as fetchImpl.RequestInit
79+
) as unknown) as ReturnType<typeof fetch>;
80+
}

0 commit comments

Comments
 (0)