Skip to content

Commit 9d9552e

Browse files
committed
[AUTOMATED]: Prettier Code Styling
1 parent 1654a71 commit 9d9552e

File tree

5 files changed

+55
-33
lines changed

5 files changed

+55
-33
lines changed

packages-exp/auth-exp/src/core/auth/auth_impl.test.ts

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@ import { browserLocalPersistence } from '../persistence/browser';
2929
import { inMemoryPersistence } from '../persistence/in_memory';
3030
import { PersistenceUserManager } from '../persistence/persistence_user_manager';
3131
import { ClientPlatform, getClientVersion } from '../util/version';
32-
import { DEFAULT_API_HOST, DEFAULT_API_SCHEME, initializeAuth } from './auth_impl';
32+
import {
33+
DEFAULT_API_HOST,
34+
DEFAULT_API_SCHEME,
35+
initializeAuth
36+
} from './auth_impl';
3337

3438
use(sinonChai);
3539

3640
const FAKE_APP: FirebaseApp = {
3741
name: 'test-app',
3842
options: {
3943
apiKey: 'api-key',
40-
authDomain: 'auth-domain',
44+
authDomain: 'auth-domain'
4145
},
4246
automaticDataCollectionEnabled: false,
43-
async delete() {},
47+
async delete() {}
4448
};
4549

4650
describe('AuthImpl', () => {
@@ -49,7 +53,7 @@ describe('AuthImpl', () => {
4953

5054
beforeEach(() => {
5155
persistenceStub = sinon.stub(inMemoryPersistence);
52-
auth = initializeAuth(FAKE_APP, {persistence: inMemoryPersistence});
56+
auth = initializeAuth(FAKE_APP, { persistence: inMemoryPersistence });
5357
});
5458

5559
afterEach(sinon.restore);
@@ -77,7 +81,7 @@ describe('AuthImpl', () => {
7781
for (let i = 0; i < 10; i++) {
7882
expect(persistenceStub.set.getCall(i)).to.have.been.calledWith(
7983
sinon.match.any,
80-
users[i].toPlainObject(),
84+
users[i].toPlainObject()
8185
);
8286
}
8387
});
@@ -101,14 +105,16 @@ describe('AuthImpl', () => {
101105
it('swaps underlying persistence', async () => {
102106
const newPersistence = browserLocalPersistence;
103107
const newStub = sinon.stub(newPersistence);
104-
persistenceStub.get.returns(Promise.resolve(testUser('test').toPlainObject()));
108+
persistenceStub.get.returns(
109+
Promise.resolve(testUser('test').toPlainObject())
110+
);
105111

106112
await auth.setPersistence(newPersistence);
107113
expect(persistenceStub.get).to.have.been.called;
108114
expect(persistenceStub.remove).to.have.been.called;
109115
expect(newStub.set).to.have.been.calledWith(
110116
sinon.match.any,
111-
testUser('test').toPlainObject(),
117+
testUser('test').toPlainObject()
112118
);
113119
});
114120
});
@@ -118,10 +124,15 @@ describe('initializeAuth', () => {
118124
afterEach(sinon.restore);
119125

120126
it('throws an API error if key not provided', () => {
121-
expect(() => initializeAuth({
122-
...FAKE_APP,
123-
options: {}, // apiKey is missing
124-
})).to.throw(FirebaseError, 'Firebase: Your API key is invalid]: please check you have copied it correctly. (auth/invalid-api-key).');
127+
expect(() =>
128+
initializeAuth({
129+
...FAKE_APP,
130+
options: {} // apiKey is missing
131+
})
132+
).to.throw(
133+
FirebaseError,
134+
'Firebase: Your API key is invalid]: please check you have copied it correctly. (auth/invalid-api-key).'
135+
);
125136
});
126137

127138
describe('persistence manager creation', () => {
@@ -130,8 +141,10 @@ describe('initializeAuth', () => {
130141
createManagerStub = sinon.spy(PersistenceUserManager, 'create');
131142
});
132143

133-
async function initAndWait(persistence: Persistence|Persistence[]): Promise<Auth> {
134-
const auth = initializeAuth(FAKE_APP, {persistence});
144+
async function initAndWait(
145+
persistence: Persistence | Persistence[]
146+
): Promise<Auth> {
147+
const auth = initializeAuth(FAKE_APP, { persistence });
135148
// Auth initializes async. We can make sure the initialization is
136149
// flushed by awaiting a method on the queue.
137150
await auth.setPersistence(inMemoryPersistence);
@@ -140,20 +153,28 @@ describe('initializeAuth', () => {
140153

141154
it('converts single persistence to array', async () => {
142155
const auth = await initAndWait(inMemoryPersistence);
143-
expect(createManagerStub).to.have.been.calledWith(auth, [inMemoryPersistence]);
156+
expect(createManagerStub).to.have.been.calledWith(auth, [
157+
inMemoryPersistence
158+
]);
144159
});
145160

146161
it('pulls the user from storage', async () => {
147-
sinon.stub(inMemoryPersistence, 'get').returns(
148-
Promise.resolve(testUser('uid').toPlainObject())
149-
);
162+
sinon
163+
.stub(inMemoryPersistence, 'get')
164+
.returns(Promise.resolve(testUser('uid').toPlainObject()));
150165
const auth = await initAndWait(inMemoryPersistence);
151166
expect(auth.currentUser!.uid).to.eq('uid');
152167
});
153168

154169
it('calls create with the persistence in order', async () => {
155-
const auth = await initAndWait([inMemoryPersistence, browserLocalPersistence]);
156-
expect(createManagerStub).to.have.been.calledWith(auth, [inMemoryPersistence, browserLocalPersistence]);
170+
const auth = await initAndWait([
171+
inMemoryPersistence,
172+
browserLocalPersistence
173+
]);
174+
expect(createManagerStub).to.have.been.calledWith(auth, [
175+
inMemoryPersistence,
176+
browserLocalPersistence
177+
]);
157178
});
158179

159180
it('sets auth name and config', async () => {
@@ -164,8 +185,8 @@ describe('initializeAuth', () => {
164185
authDomain: FAKE_APP.options.authDomain,
165186
apiHost: DEFAULT_API_HOST,
166187
apiScheme: DEFAULT_API_SCHEME,
167-
sdkClientVersion: getClientVersion(ClientPlatform.BROWSER),
188+
sdkClientVersion: getClientVersion(ClientPlatform.BROWSER)
168189
});
169190
});
170191
});
171-
});
192+
});

packages-exp/auth-exp/src/core/auth/auth_impl.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ export const DEFAULT_API_HOST = 'identitytoolkit.googleapis.com';
3434
export const DEFAULT_API_SCHEME = 'https';
3535

3636
class AuthImpl implements Auth {
37-
currentUser: User|null = null;
37+
currentUser: User | null = null;
3838
private operations: Promise<void>;
3939
private persistenceManager?: PersistenceUserManager;
4040

4141
constructor(
42-
public readonly name: string,
43-
public readonly config: Config,
44-
persistenceHierarchy: Persistence[]) {
42+
public readonly name: string,
43+
public readonly config: Config,
44+
persistenceHierarchy: Persistence[]
45+
) {
4546
this.operations = Promise.resolve();
4647

4748
// This promise is intended to float; auth initialization happens in the
@@ -50,7 +51,7 @@ class AuthImpl implements Auth {
5051
this.queue(async () => {
5152
this.persistenceManager = await PersistenceUserManager.create(
5253
this,
53-
persistenceHierarchy,
54+
persistenceHierarchy
5455
);
5556

5657
const storedUser = await this.persistenceManager.getCurrentUser();
@@ -104,20 +105,20 @@ class AuthImpl implements Auth {
104105

105106
export function initializeAuth(
106107
app: FirebaseApp = getApp(),
107-
deps?: Dependencies,
108+
deps?: Dependencies
108109
): Auth {
109110
const persistence = deps?.persistence || [];
110111
const hierarchy = Array.isArray(persistence) ? persistence : [persistence];
111-
const {apiKey, authDomain} = app.options;
112+
const { apiKey, authDomain } = app.options;
112113

113114
// TODO: platform needs to be determined using heuristics
114115
const config: Config = {
115116
apiKey: assert(apiKey, app.name, AuthErrorCode.INVALID_API_KEY),
116117
authDomain,
117118
apiHost: DEFAULT_API_HOST,
118119
apiScheme: DEFAULT_API_SCHEME,
119-
sdkClientVersion: getClientVersion(ClientPlatform.BROWSER),
120+
sdkClientVersion: getClientVersion(ClientPlatform.BROWSER)
120121
};
121-
122+
122123
return new AuthImpl(app.name, config, hierarchy);
123124
}

packages-exp/auth-exp/src/core/util/assert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { AUTH_ERROR_FACTORY, AuthErrorCode } from '../errors';
2020
export function assert<T>(
2121
expression: T | null | undefined,
2222
appName: string,
23-
code = AuthErrorCode.INTERNAL_ERROR,
23+
code = AuthErrorCode.INTERNAL_ERROR
2424
): T {
2525
if (!expression) {
2626
throw AUTH_ERROR_FACTORY.create(code, { appName });

packages-exp/auth-exp/src/model/auth.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ export interface Auth {
4242

4343
export interface Dependencies {
4444
persistence?: Persistence | Persistence[];
45-
}
45+
}

packages-exp/auth-exp/test/mock_auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const mockAuth: Auth = {
3535
currentUser: null,
3636
async setPersistence() {},
3737
async updateCurrentUser() {},
38-
async signOut() {},
38+
async signOut() {}
3939
};
4040

4141
export function testUser(uid: string): User {

0 commit comments

Comments
 (0)