Skip to content

Commit e0ba6df

Browse files
committed
Added tests.
1 parent 177cde1 commit e0ba6df

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

packages/auth/src/core/auth/emulator.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,41 @@ describe('core/auth/emulator', () => {
7676
);
7777
});
7878

79+
it('passes with same config if a network request has already been made', async () => {
80+
expect(() => connectAuthEmulator(auth, 'http://127.0.0.1:2020')).to.not
81+
.throw;
82+
await user.delete();
83+
expect(() => connectAuthEmulator(auth, 'http://127.0.0.1:2020')).to.not
84+
.throw;
85+
});
86+
87+
it('fails with differeing config if a network request has already been made', async () => {
88+
expect(() => connectAuthEmulator(auth, 'http://127.0.0.1:2020')).to.not
89+
.throw;
90+
await user.delete();
91+
expect(() => connectAuthEmulator(auth, 'http://127.0.0.1:2021')).to.throw(
92+
FirebaseError,
93+
'auth/emulator-config-failed'
94+
);
95+
});
96+
97+
it('subsequent calls update the endpoint appropriately', async () => {
98+
connectAuthEmulator(auth, 'http://127.0.0.2:2020');
99+
expect(auth.emulatorConfig).to.eql({
100+
protocol: 'http',
101+
host: '127.0.0.2',
102+
port: 2020,
103+
options: { disableWarnings: false }
104+
});
105+
connectAuthEmulator(auth, 'http://127.0.0.1:2020');
106+
expect(auth.emulatorConfig).to.eql({
107+
protocol: 'http',
108+
host: '127.0.0.1',
109+
port: 2020,
110+
options: { disableWarnings: false }
111+
});
112+
});
113+
79114
it('updates the endpoint appropriately', async () => {
80115
connectAuthEmulator(auth, 'http://127.0.0.1:2020');
81116
await user.delete();

packages/auth/src/core/auth/emulator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { _castAuth } from './auth_impl';
4444
export function connectAuthEmulator(
4545
auth: Auth,
4646
url: string,
47-
options: { disableWarnings: boolean } = { disableWarnings: false }
47+
options?: { disableWarnings: boolean }
4848
): void {
4949
const authInternal = _castAuth(auth);
5050
_assert(

0 commit comments

Comments
 (0)