@@ -28,7 +28,7 @@ import * as fetch from '../../../test/helpers/mock_fetch';
2828import { Endpoint } from '../../api' ;
2929import { UserInternal } from '../../model/user' ;
3030import { _castAuth } from './auth_impl' ;
31- import { useAuthEmulator } from './emulator' ;
31+ import { connectAuthEmulator } from './emulator' ;
3232
3333use ( sinonChai ) ;
3434use ( chaiAsPromised ) ;
@@ -67,48 +67,49 @@ describe('core/auth/emulator', () => {
6767 }
6868 } ) ;
6969
70- context ( 'useAuthEmulator ' , ( ) => {
70+ context ( 'connectAuthEmulator ' , ( ) => {
7171 it ( 'fails if a network request has already been made' , async ( ) => {
7272 await user . delete ( ) ;
73- expect ( ( ) => useAuthEmulator ( auth , 'http://localhost:2020' ) ) . to . throw (
73+ expect ( ( ) => connectAuthEmulator ( auth , 'http://localhost:2020' ) ) . to . throw (
7474 FirebaseError ,
7575 'auth/emulator-config-failed'
7676 ) ;
7777 } ) ;
7878
7979 it ( 'updates the endpoint appropriately' , async ( ) => {
80- useAuthEmulator ( auth , 'http://localhost:2020' ) ;
80+ connectAuthEmulator ( auth , 'http://localhost:2020' ) ;
8181 await user . delete ( ) ;
8282 expect ( normalEndpoint . calls . length ) . to . eq ( 0 ) ;
8383 expect ( emulatorEndpoint . calls . length ) . to . eq ( 1 ) ;
8484 } ) ;
8585
8686 it ( 'updates the endpoint appropriately with trailing slash' , async ( ) => {
87- useAuthEmulator ( auth , 'http://localhost:2020/' ) ;
87+ connectAuthEmulator ( auth , 'http://localhost:2020/' ) ;
8888 await user . delete ( ) ;
8989 expect ( normalEndpoint . calls . length ) . to . eq ( 0 ) ;
9090 expect ( emulatorEndpoint . calls . length ) . to . eq ( 1 ) ;
9191 } ) ;
9292
9393 it ( 'checks the scheme properly' , ( ) => {
94- expect ( ( ) => useAuthEmulator ( auth , 'http://localhost:2020' ) ) . not . to . throw ;
94+ expect ( ( ) => connectAuthEmulator ( auth , 'http://localhost:2020' ) ) . not . to
95+ . throw ;
9596 delete auth . config . emulator ;
96- expect ( ( ) => useAuthEmulator ( auth , 'https://localhost:2020' ) ) . not . to
97+ expect ( ( ) => connectAuthEmulator ( auth , 'https://localhost:2020' ) ) . not . to
9798 . throw ;
9899 delete auth . config . emulator ;
99- expect ( ( ) => useAuthEmulator ( auth , 'ssh://localhost:2020' ) ) . to . throw (
100+ expect ( ( ) => connectAuthEmulator ( auth , 'ssh://localhost:2020' ) ) . to . throw (
100101 FirebaseError ,
101102 'auth/invalid-emulator-scheme'
102103 ) ;
103104 delete auth . config . emulator ;
104- expect ( ( ) => useAuthEmulator ( auth , 'localhost:2020' ) ) . to . throw (
105+ expect ( ( ) => connectAuthEmulator ( auth , 'localhost:2020' ) ) . to . throw (
105106 FirebaseError ,
106107 'auth/invalid-emulator-scheme'
107108 ) ;
108109 } ) ;
109110
110111 it ( 'attaches a banner to the DOM' , ( ) => {
111- useAuthEmulator ( auth , 'http://localhost:2020' ) ;
112+ connectAuthEmulator ( auth , 'http://localhost:2020' ) ;
112113 if ( typeof document !== 'undefined' ) {
113114 const el = document . querySelector ( '.firebase-emulator-warning' ) ! ;
114115 expect ( el ) . not . to . be . null ;
@@ -121,7 +122,7 @@ describe('core/auth/emulator', () => {
121122
122123 it ( 'logs out a warning to the console' , ( ) => {
123124 sinon . stub ( console , 'info' ) ;
124- useAuthEmulator ( auth , 'http://localhost:2020' ) ;
125+ connectAuthEmulator ( auth , 'http://localhost:2020' ) ;
125126 expect ( console . info ) . to . have . been . calledWith (
126127 'WARNING: You are using the Auth Emulator,' +
127128 ' which is intended for local testing only. Do not use with' +
@@ -131,7 +132,9 @@ describe('core/auth/emulator', () => {
131132
132133 it ( 'logs out the warning but has no banner if disableBanner true' , ( ) => {
133134 sinon . stub ( console , 'info' ) ;
134- useAuthEmulator ( auth , 'http://localhost:2020' , { disableWarnings : true } ) ;
135+ connectAuthEmulator ( auth , 'http://localhost:2020' , {
136+ disableWarnings : true
137+ } ) ;
135138 expect ( console . info ) . to . have . been . calledWith (
136139 'WARNING: You are using the Auth Emulator,' +
137140 ' which is intended for local testing only. Do not use with' +
@@ -143,7 +146,7 @@ describe('core/auth/emulator', () => {
143146 } ) ;
144147
145148 it ( 'sets emulatorConfig on the Auth object' , async ( ) => {
146- useAuthEmulator ( auth , 'http://localhost:2020' ) ;
149+ connectAuthEmulator ( auth , 'http://localhost:2020' ) ;
147150 expect ( auth . emulatorConfig ) . to . eql ( {
148151 protocol : 'http' ,
149152 host : 'localhost' ,
@@ -153,7 +156,7 @@ describe('core/auth/emulator', () => {
153156 } ) ;
154157
155158 it ( 'sets disableWarnings in emulatorConfig accordingly' , async ( ) => {
156- useAuthEmulator ( auth , 'https://127.0.0.1' , { disableWarnings : true } ) ;
159+ connectAuthEmulator ( auth , 'https://127.0.0.1' , { disableWarnings : true } ) ;
157160 expect ( auth . emulatorConfig ) . to . eql ( {
158161 protocol : 'https' ,
159162 host : '127.0.0.1' ,
@@ -163,7 +166,7 @@ describe('core/auth/emulator', () => {
163166 } ) ;
164167
165168 it ( 'quotes IPv6 address in emulatorConfig' , async ( ) => {
166- useAuthEmulator ( auth , 'http://[::1]:2020/' ) ;
169+ connectAuthEmulator ( auth , 'http://[::1]:2020/' ) ;
167170 expect ( auth . emulatorConfig ) . to . eql ( {
168171 protocol : 'http' ,
169172 host : '[::1]' ,
@@ -181,9 +184,9 @@ describe('core/auth/emulator', () => {
181184 } ) ;
182185
183186 it ( 'also stringifies the current user' , ( ) => {
184- auth . currentUser = ( {
187+ auth . currentUser = {
185188 toJSON : ( ) : object => ( { foo : 'bar' } )
186- } as unknown ) as UserInternal ;
189+ } as unknown as UserInternal ;
187190 expect ( JSON . stringify ( auth ) ) . to . eq (
188191 '{"apiKey":"test-api-key","authDomain":"localhost",' +
189192 '"appName":"test-app","currentUser":{"foo":"bar"}}'
0 commit comments