@@ -64,7 +64,8 @@ import {
64
64
import {
65
65
ALT_PROJECT_ID ,
66
66
DEFAULT_PROJECT_ID ,
67
- TARGET_DB_ID
67
+ TARGET_DB_ID ,
68
+ USE_EMULATOR
68
69
} from '../util/settings' ;
69
70
70
71
// We're using 'as any' to pass invalid values to APIs for testing purposes.
@@ -177,6 +178,18 @@ apiDescribe('Validation:', persistence => {
177
178
}
178
179
) ;
179
180
181
+ validationIt (
182
+ persistence ,
183
+ 'connectFirestoreEmulator() can set mockUserToken object' ,
184
+ ( ) => {
185
+ const db = newTestFirestore ( newTestApp ( 'test-project' ) ) ;
186
+ // Verify that this doesn't throw.
187
+ connectFirestoreEmulator ( db , '127.0.0.1' , 9000 , {
188
+ mockUserToken : { sub : 'foo' }
189
+ } ) ;
190
+ }
191
+ ) ;
192
+
180
193
validationIt (
181
194
persistence ,
182
195
'disallows calling connectFirestoreEmulator() for first time after use' ,
@@ -195,37 +208,29 @@ apiDescribe('Validation:', persistence => {
195
208
persistence ,
196
209
'allows calling connectFirestoreEmulator() after use with same config' ,
197
210
async db => {
198
- connectFirestoreEmulator ( db , '127.0.0.1' , 9000 ) ;
199
- await setDoc ( doc ( db , 'foo/bar' ) , { } ) ;
200
- expect ( ( ) =>
201
- connectFirestoreEmulator ( db , '127.0.0.1' , 9000 )
202
- ) . to . not . throw ( ) ;
211
+ if ( USE_EMULATOR ) {
212
+ connectFirestoreEmulator ( db , '127.0.0.1' , 9000 ) ;
213
+ await setDoc ( doc ( db , 'foo/bar' ) , { } ) ;
214
+ expect ( ( ) =>
215
+ connectFirestoreEmulator ( db , '127.0.0.1' , 9000 )
216
+ ) . to . not . throw ( ) ;
217
+ }
203
218
}
204
219
) ;
205
220
206
221
validationIt (
207
222
persistence ,
208
223
'disallows calling connectFirestoreEmulator() after use with different config' ,
209
224
async db => {
210
- const errorMsg =
211
- 'Firestore has already been started and its settings can no longer be changed.' ;
212
- connectFirestoreEmulator ( db , '127.0.0.1' , 9000 ) ;
213
- await setDoc ( doc ( db , 'foo/bar' ) , { } ) ;
214
- expect ( ( ) => connectFirestoreEmulator ( db , '127.0.0.1' , 9001 ) ) . to . throw (
215
- errorMsg
216
- ) ;
217
- }
218
- ) ;
219
-
220
- validationIt (
221
- persistence ,
222
- 'connectFirestoreEmulator() can set mockUserToken object' ,
223
- ( ) => {
224
- const db = newTestFirestore ( newTestApp ( 'test-project' ) ) ;
225
- // Verify that this doesn't throw.
226
- connectFirestoreEmulator ( db , '127.0.0.1' , 9000 , {
227
- mockUserToken : { sub : 'foo' }
228
- } ) ;
225
+ if ( USE_EMULATOR ) {
226
+ const errorMsg =
227
+ 'Firestore has already been started and its settings can no longer be changed.' ;
228
+ connectFirestoreEmulator ( db , '127.0.0.1' , 9000 ) ;
229
+ await setDoc ( doc ( db , 'foo/bar' ) , { } ) ;
230
+ expect ( ( ) =>
231
+ connectFirestoreEmulator ( db , '127.0.0.1' , 9001 )
232
+ ) . to . throw ( errorMsg ) ;
233
+ }
229
234
}
230
235
) ;
231
236
0 commit comments