@@ -238,22 +238,23 @@ apiDescribe('Validation:', (persistence: boolean) => {
238
238
describe ( 'Collection paths' , ( ) => {
239
239
validationIt ( persistence , 'must be non-empty strings' , db => {
240
240
const baseDocRef = db . doc ( 'foo/bar' ) ;
241
- const argumentPosition = usesFunctionalApi ( ) ? 'second' : 'first' ;
242
241
243
- expect ( ( ) => db . collection ( '' ) ) . to . throw (
244
- `Function ${
245
- usesFunctionalApi ( ) ? 'collection' : 'Firestore.collection'
246
- } () requires its ${ argumentPosition } argument to be of type ` +
247
- 'non-empty string, but it was: ""'
248
- ) ;
249
- expect ( ( ) => baseDocRef . collection ( '' ) ) . to . throw (
250
- `Function ${
251
- usesFunctionalApi ( ) ? 'collection' : 'DocumentReference.collection'
252
- } () requires its ${ argumentPosition } argument to be of type ` +
253
- 'non-empty string, but it was: ""'
254
- ) ;
255
-
256
- if ( validatesJsInput ) {
242
+ if ( usesFunctionalApi ( ) ) {
243
+ expect ( ( ) => db . collection ( '' ) ) . to . throw (
244
+ 'Function collection() cannot be called with an empty path.'
245
+ ) ;
246
+ expect ( ( ) => baseDocRef . collection ( '' ) ) . to . throw (
247
+ 'Function DocumentReference.collection() cannot be called with an empty path.'
248
+ ) ;
249
+ } else {
250
+ expect ( ( ) => db . collection ( '' ) ) . to . throw (
251
+ 'Function Firestore.collection() requires its first ' +
252
+ 'argument to be of type non-empty string, but it was: ""'
253
+ ) ;
254
+ expect ( ( ) => baseDocRef . collection ( '' ) ) . to . throw (
255
+ 'Function DocumentReference.collection() requires its first ' +
256
+ 'argument to be of type non-empty string, but it was: ""'
257
+ ) ;
257
258
expect ( ( ) => db . collection ( null as any ) ) . to . throw (
258
259
'Function Firestore.collection() requires its first argument ' +
259
260
'to be of type non-empty string, but it was: null'
@@ -309,21 +310,23 @@ apiDescribe('Validation:', (persistence: boolean) => {
309
310
describe ( 'Document paths' , ( ) => {
310
311
validationIt ( persistence , 'must be strings' , db => {
311
312
const baseCollectionRef = db . collection ( 'foo' ) ;
312
- const argumentPosition = usesFunctionalApi ( ) ? 'second' : 'first' ;
313
313
314
- expect ( ( ) => db . doc ( '' ) ) . to . throw (
315
- `Function ${ usesFunctionalApi ( ) ? 'doc' : 'Firestore.doc' } () ` +
316
- `requires its ${ argumentPosition } argument to be of type non-empty ` +
317
- 'string, but it was: ""'
318
- ) ;
319
- expect ( ( ) => baseCollectionRef . doc ( '' ) ) . to . throw (
320
- `Function ${
321
- usesFunctionalApi ( ) ? 'doc' : 'CollectionReference.doc'
322
- } () requires its ${ argumentPosition } argument to be of type ` +
323
- 'non-empty string, but it was: ""'
324
- ) ;
325
-
326
- if ( validatesJsInput ) {
314
+ if ( usesFunctionalApi ( ) ) {
315
+ expect ( ( ) => db . doc ( '' ) ) . to . throw (
316
+ 'Function doc() cannot be called with an empty path.'
317
+ ) ;
318
+ expect ( ( ) => baseCollectionRef . doc ( '' ) ) . to . throw (
319
+ 'Function CollectionReference.doc() cannot be called with an empty path.'
320
+ ) ;
321
+ } else {
322
+ expect ( ( ) => db . doc ( '' ) ) . to . throw (
323
+ 'Function Firestore.doc() requires its first ' +
324
+ 'argument to be of type non-empty string, but it was: ""'
325
+ ) ;
326
+ expect ( ( ) => baseCollectionRef . doc ( '' ) ) . to . throw (
327
+ 'Function CollectionReference.doc() requires its first ' +
328
+ 'argument to be of type non-empty string, but it was: ""'
329
+ ) ;
327
330
expect ( ( ) => db . doc ( null as any ) ) . to . throw (
328
331
'Function Firestore.doc() requires its first argument to be ' +
329
332
'of type non-empty string, but it was: null'
0 commit comments