Skip to content

Commit b5e778a

Browse files
committed
Formatting
1 parent c3a73b2 commit b5e778a

File tree

6 files changed

+77
-36
lines changed

6 files changed

+77
-36
lines changed

packages-exp/auth-exp/src/platform_browser/iframe/gapi.iframes.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ declare namespace gapi.iframes {
4141
}
4242

4343
type IframesFilter = (iframe: Iframe) => boolean;
44-
type MessageHandler<T extends Message> = (message: T) => unknown | Promise<void>;
44+
type MessageHandler<T extends Message> = (
45+
message: T
46+
) => unknown | Promise<void>;
4547
type SendCallback = () => void;
4648
type StyleHandler = (options: OptionsBag) => void;
4749
type RpcFilter = (iframe: Iframe) => boolean | Promise<boolean>;

packages-exp/auth-exp/src/platform_browser/iframe/gapi.test.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ describe('src/platform_browser/iframe/gapi', () => {
4040
}
4141

4242
beforeEach(async () => {
43-
4443
const head = document.createElement('div');
4544
tag = document.createElement('script');
4645

4746
sinon.stub(document, 'createElement').returns(tag);
48-
sinon.stub(document, 'getElementsByTagName').returns([head] as unknown as HTMLCollection);
47+
sinon
48+
.stub(document, 'getElementsByTagName')
49+
.returns(([head] as unknown) as HTMLCollection);
4950
sinon.stub(head, 'appendChild').callsFake(() => {
5051
onJsLoad();
5152
return head;
@@ -54,12 +55,19 @@ describe('src/platform_browser/iframe/gapi', () => {
5455
auth = await testAuth();
5556
});
5657

57-
function makeGapi(result: unknown, timesout = false): Record<string, unknown> {
58+
function makeGapi(
59+
result: unknown,
60+
timesout = false
61+
): Record<string, unknown> {
5862
const callbackFn = timesout === false ? 'callback' : 'ontimeout';
5963
return {
60-
load: sinon.stub().callsFake((_name: string, params: Record<string, Function>) => params[callbackFn]()),
64+
load: sinon
65+
.stub()
66+
.callsFake((_name: string, params: Record<string, Function>) =>
67+
params[callbackFn]()
68+
),
6169
iframes: {
62-
getContext: () => result,
70+
getContext: () => result
6371
}
6472
};
6573
}
@@ -83,7 +91,7 @@ describe('src/platform_browser/iframe/gapi', () => {
8391
H: {
8492
something: {
8593
r: ['requested'],
86-
L: ['loaded', 'test'],
94+
L: ['loaded', 'test']
8795
}
8896
},
8997
CP: [1, 2, 3, 4]
@@ -92,7 +100,7 @@ describe('src/platform_browser/iframe/gapi', () => {
92100
library = makeGapi('iframes');
93101

94102
await _loadGapi(auth);
95-
103+
96104
// Expect deep equality, but *not* pointer equality
97105
expect(AUTH_WINDOW.___jsl.H.something.r).to.eql(
98106
AUTH_WINDOW.___jsl.H.something.L
@@ -114,18 +122,27 @@ describe('src/platform_browser/iframe/gapi', () => {
114122

115123
it('rejects with a network error if load fails', async () => {
116124
library = {};
117-
await expect(_loadGapi(auth)).to.be.rejectedWith(FirebaseError, 'auth/network-request-failed');
125+
await expect(_loadGapi(auth)).to.be.rejectedWith(
126+
FirebaseError,
127+
'auth/network-request-failed'
128+
);
118129
});
119130

120131
it('rejects with a network error if ontimeout called', async () => {
121132
library = makeGapi(undefined, /* timesout */ true);
122-
await expect(_loadGapi(auth)).to.be.rejectedWith(FirebaseError, 'auth/network-request-failed');
133+
await expect(_loadGapi(auth)).to.be.rejectedWith(
134+
FirebaseError,
135+
'auth/network-request-failed'
136+
);
123137
});
124138

125139
it('resets the load promise if the load errors', async () => {
126140
library = {};
127141
const firstAttempt = _loadGapi(auth);
128-
await expect(firstAttempt).to.be.rejectedWith(FirebaseError, 'auth/network-request-failed');
142+
await expect(firstAttempt).to.be.rejectedWith(
143+
FirebaseError,
144+
'auth/network-request-failed'
145+
);
129146
expect(_loadGapi(auth)).not.to.eq(firstAttempt);
130147
});
131-
});
148+
});

packages-exp/auth-exp/src/platform_browser/iframe/gapi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ function loadGapi(auth: Auth): Promise<gapi.iframes.Context> {
8282
},
8383
timeout: NETWORK_TIMEOUT.get()
8484
});
85-
};
86-
85+
}
86+
8787
if (AUTH_WINDOW.gapi?.iframes?.Iframe) {
8888
// If gapi.iframes.Iframe available, resolve.
8989
resolve(gapi.iframes.getContext());
@@ -130,4 +130,4 @@ export function _loadGapi(auth: Auth): Promise<gapi.iframes.Context> {
130130

131131
export function _resetLoader(): void {
132132
cachedGApiLoader = null;
133-
}
133+
}

packages-exp/auth-exp/src/platform_browser/iframe/iframe.test.ts

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,25 @@ describe('src/platform_browser/iframe/iframe', () => {
4141
let libraryLoadedCallback: IframesCallback;
4242

4343
beforeEach(async () => {
44-
AUTH_WINDOW.gapi = {iframes: {
45-
CROSS_ORIGIN_IFRAMES_FILTER: 'cross-origin-filter',
46-
}} as unknown as typeof gapi;
44+
AUTH_WINDOW.gapi = ({
45+
iframes: {
46+
CROSS_ORIGIN_IFRAMES_FILTER: 'cross-origin-filter'
47+
}
48+
} as unknown) as typeof gapi;
4749
auth = await testAuth();
48-
49-
sinon.stub(gapiLoader, '_loadGapi').returns(Promise.resolve({
50-
open: sinon.stub().callsFake((settings: Record<string, unknown>, cb: IframesCallback) => {
51-
iframeSettings = settings;
52-
libraryLoadedCallback = cb;
53-
})
54-
}) as unknown as Promise<gapi.iframes.Context>);
50+
51+
sinon.stub(gapiLoader, '_loadGapi').returns(
52+
(Promise.resolve({
53+
open: sinon
54+
.stub()
55+
.callsFake(
56+
(settings: Record<string, unknown>, cb: IframesCallback) => {
57+
iframeSettings = settings;
58+
libraryLoadedCallback = cb;
59+
}
60+
)
61+
}) as unknown) as Promise<gapi.iframes.Context>
62+
);
5563
});
5664

5765
afterEach(() => {
@@ -63,9 +71,11 @@ describe('src/platform_browser/iframe/iframe', () => {
6371
console.warn(iframeSettings);
6472

6573
expect(iframeSettings.where).to.eql(document.body);
66-
expect(iframeSettings.url).to.eq(`https://${TEST_AUTH_DOMAIN}/__/auth/iframe?apiKey=${TEST_KEY}&appName=test-app&v=${SDK_VERSION}`);
74+
expect(iframeSettings.url).to.eq(
75+
`https://${TEST_AUTH_DOMAIN}/__/auth/iframe?apiKey=${TEST_KEY}&appName=test-app&v=${SDK_VERSION}`
76+
);
6777
expect(iframeSettings.messageHandlersFilter).to.eq('cross-origin-filter');
68-
expect(iframeSettings.attributes).to.eql( {
78+
expect(iframeSettings.attributes).to.eql({
6979
style: {
7080
position: 'absolute',
7181
top: '-100px',
@@ -81,10 +91,10 @@ describe('src/platform_browser/iframe/iframe', () => {
8191
let clearTimeoutStub: sinon.SinonStub;
8292

8393
beforeEach(() => {
84-
iframe = sinon.stub({
94+
iframe = sinon.stub(({
8595
restyle: () => {},
8696
ping: () => {}
87-
} as unknown as gapi.iframes.Iframe);
97+
} as unknown) as gapi.iframes.Iframe);
8898
clearTimeoutStub = sinon.stub(AUTH_WINDOW, 'clearTimeout');
8999
});
90100

@@ -100,7 +110,10 @@ describe('src/platform_browser/iframe/iframe', () => {
100110
it('rejects if the iframe ping promise rejects', async () => {
101111
stubSingleTimeout();
102112
iframe.ping.returns(Promise.reject('no'));
103-
await expect(libraryLoadedCallback(iframe)).to.be.rejectedWith(FirebaseError, 'auth/network-request-failed');
113+
await expect(libraryLoadedCallback(iframe)).to.be.rejectedWith(
114+
FirebaseError,
115+
'auth/network-request-failed'
116+
);
104117
});
105118

106119
it('clears the rejection timeout on success', async () => {
@@ -110,4 +123,4 @@ describe('src/platform_browser/iframe/iframe', () => {
110123
expect(clearTimeoutStub).to.have.been.calledWith(123);
111124
});
112125
});
113-
});
126+
});

packages-exp/auth-exp/src/platform_browser/iframe/iframe.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ export async function _openIframe(auth: Auth): Promise<gapi.iframes.Iframe> {
5454
{
5555
where: document.body,
5656
url: getIframeUrl(auth),
57-
messageHandlersFilter: AUTH_WINDOW.gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER,
57+
messageHandlersFilter:
58+
AUTH_WINDOW.gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER,
5859
attributes: IFRAME_ATTRIBUTES,
5960
dontclear: true
6061
},
61-
(iframe: gapi.iframes.Iframe) => new Promise(async (resolve, reject) => {
62+
(iframe: gapi.iframes.Iframe) =>
63+
new Promise(async (resolve, reject) => {
6264
await iframe.restyle({
6365
// Prevent iframe from closing on mouse out.
6466
setHideOnLeave: false
@@ -77,7 +79,7 @@ export async function _openIframe(auth: Auth): Promise<gapi.iframes.Iframe> {
7779
function clearTimerAndResolve(): void {
7880
AUTH_WINDOW.clearTimeout(networkErrorTimer);
7981
resolve(iframe);
80-
};
82+
}
8183
// This returns an IThenable. However the reject part does not call
8284
// when the iframe is not loaded.
8385
iframe.ping(clearTimerAndResolve).then(clearTimerAndResolve, () => {
@@ -87,5 +89,6 @@ export async function _openIframe(auth: Auth): Promise<gapi.iframes.Iframe> {
8789
})
8890
);
8991
});
90-
}));
92+
})
93+
);
9194
}

packages-exp/auth-types-exp/index.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { CompleteFn, ErrorFn, NextFn, Observer, Unsubscribe } from '@firebase/util';
18+
import {
19+
CompleteFn,
20+
ErrorFn,
21+
NextFn,
22+
Observer,
23+
Unsubscribe
24+
} from '@firebase/util';
1925

2026
/**
2127
* Supported providers

0 commit comments

Comments
 (0)