Skip to content

Commit 486721c

Browse files
committed
Added tests
1 parent a6edd0c commit 486721c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { Endpoint } from '../../api';
2929
import { UserInternal } from '../../model/user';
3030
import { _castAuth } from './auth_impl';
3131
import { connectAuthEmulator } from './emulator';
32+
import * as Util from '@firebase/util';
3233

3334
use(sinonChai);
3435
use(chaiAsPromised);
@@ -38,8 +39,10 @@ describe('core/auth/emulator', () => {
3839
let user: UserInternal;
3940
let normalEndpoint: fetch.Route;
4041
let emulatorEndpoint: fetch.Route;
42+
let testStub: sinon.SinonStub;
4143

4244
beforeEach(async () => {
45+
testStub = sinon.stub(Util, 'pingServer');
4346
auth = await testAuth();
4447
user = testUser(_castAuth(auth), 'uid', 'email', true);
4548
fetch.setUp();
@@ -154,6 +157,19 @@ describe('core/auth/emulator', () => {
154157
);
155158
}
156159
});
160+
it('calls pingServer with port if specified', () => {
161+
connectAuthEmulator(auth, 'https://abc.cloudworkstations.dev:2020');
162+
expect(testStub).to.have.been.calledWith(
163+
'https://abc.cloudworkstations.dev:2020'
164+
);
165+
});
166+
167+
it('calls pingServer with no port if none specified', () => {
168+
connectAuthEmulator(auth, 'https://abc.cloudworkstations.dev');
169+
expect(testStub).to.have.been.calledWith(
170+
'https://abc.cloudworkstations.dev'
171+
);
172+
});
157173

158174
it('logs out a warning to the console', () => {
159175
sinon.stub(console, 'info');

0 commit comments

Comments
 (0)