@@ -31,7 +31,6 @@ import { ALT_PROJECT_ID, DEFAULT_PROJECT_ID } from '../util/settings';
31
31
const FieldPath = firebaseExport . FieldPath ;
32
32
const FieldValue = firebaseExport . FieldValue ;
33
33
const newTestFirestore = firebaseExport . newTestFirestore ;
34
- const usesFunctionalApi = firebaseExport . usesFunctionalApi ;
35
34
36
35
// We're using 'as any' to pass invalid values to APIs for testing purposes.
37
36
/* eslint-disable @typescript-eslint/no-explicit-any */
@@ -117,24 +116,14 @@ apiDescribe('Validation:', (persistence: boolean) => {
117
116
persistence ,
118
117
'disallows changing settings after use' ,
119
118
async db => {
120
- let errorMsg =
121
- 'Firestore has already been started and its settings can no ' +
122
- 'longer be changed. ' ;
123
-
124
- if ( usesFunctionalApi ( ) ) {
125
- errorMsg +=
126
- 'initializeFirestore() cannot be called after calling ' +
127
- 'getFirestore()' ;
128
- } else {
129
- errorMsg +=
130
- 'You can only modify settings before calling any other ' +
131
- 'methods on a Firestore object.' ;
132
- }
133
-
134
119
await db . doc ( 'foo/bar' ) . set ( { } ) ;
135
120
expect ( ( ) =>
136
121
db . settings ( { host : 'something-else.example.com' } )
137
- ) . to . throw ( errorMsg ) ;
122
+ ) . to . throw (
123
+ 'Firestore has already been started and its settings can no ' +
124
+ 'longer be changed. You can only modify settings before calling any other ' +
125
+ 'methods on a Firestore object.'
126
+ ) ;
138
127
}
139
128
) ;
140
129
@@ -661,10 +650,9 @@ apiDescribe('Validation:', (persistence: boolean) => {
661
650
expect ( ( ) =>
662
651
collection . where ( 'test' , '==' , { test : FieldValue . increment ( 1 ) } )
663
652
) . to . throw (
664
- `Function ${
665
- usesFunctionalApi ( ) ? 'where' : 'Query.where'
666
- } () called with invalid data. FieldValue.increment() can only be ` +
667
- 'used with update() and set() (found in field test)'
653
+ 'Function Query.where() called with invalid data. ' +
654
+ 'FieldValue.increment() can only be used with update() and set() ' +
655
+ '(found in field test)'
668
656
) ;
669
657
} ) ;
670
658
} ) ;
@@ -673,14 +661,10 @@ apiDescribe('Validation:', (persistence: boolean) => {
673
661
validationIt ( persistence , 'with non-positive limit fail' , db => {
674
662
const collection = db . collection ( 'test' ) ;
675
663
expect ( ( ) => collection . limit ( 0 ) ) . to . throw (
676
- `Function ${
677
- usesFunctionalApi ( ) ? 'limit' : 'Query.limit'
678
- } () requires a positive number, but it was: 0.`
664
+ `Function Query.limit() requires a positive number, but it was: 0.`
679
665
) ;
680
666
expect ( ( ) => collection . limitToLast ( - 1 ) ) . to . throw (
681
- `Function ${
682
- usesFunctionalApi ( ) ? 'limitToLast' : 'Query.limitToLast'
683
- } () requires a positive number, but it was: -1.`
667
+ `Function Query.limitToLast() requires a positive number, but it was: -1.`
684
668
) ;
685
669
} ) ;
686
670
@@ -771,10 +755,9 @@ apiDescribe('Validation:', (persistence: boolean) => {
771
755
const collection = db . collection ( 'collection' ) ;
772
756
const query = collection . orderBy ( 'foo' ) ;
773
757
const reason =
774
- `Too many arguments provided to ${
775
- usesFunctionalApi ( ) ? 'startAt' : 'Query.startAt'
776
- } (). The number of arguments must be less than or equal to the ` +
777
- `number of orderBy() clauses` ;
758
+ 'Too many arguments provided to Query.startAt(). The number of ' +
759
+ 'arguments must be less than or equal to the number of orderBy() ' +
760
+ 'clauses' ;
778
761
expect ( ( ) => query . startAt ( 1 , 2 ) ) . to . throw ( reason ) ;
779
762
expect ( ( ) => query . orderBy ( 'bar' ) . startAt ( 1 , 2 , 3 ) ) . to . throw ( reason ) ;
780
763
}
@@ -792,22 +775,18 @@ apiDescribe('Validation:', (persistence: boolean) => {
792
775
. orderBy ( FieldPath . documentId ( ) ) ;
793
776
expect ( ( ) => query . startAt ( 1 ) ) . to . throw (
794
777
'Invalid query. Expected a string for document ID in ' +
795
- `${
796
- usesFunctionalApi ( ) ? 'startAt' : 'Query.startAt'
797
- } (), but got a number`
778
+ 'Query.startAt(), but got a number'
798
779
) ;
799
780
expect ( ( ) => query . startAt ( 'foo/bar' ) ) . to . throw (
800
- `Invalid query. When querying a collection and ordering by FieldPath.documentId(), ` +
801
- `the value passed to ${
802
- usesFunctionalApi ( ) ? 'startAt' : 'Query.startAt'
803
- } () must be a plain document ID, but 'foo/bar' contains a slash.`
781
+ 'Invalid query. When querying a collection and ordering by FieldPath.documentId(), ' +
782
+ 'the value passed to Query.startAt() must be a plain document ID, ' +
783
+ "but 'foo/bar' contains a slash."
804
784
) ;
805
785
expect ( ( ) => cgQuery . startAt ( 'foo' ) ) . to . throw (
806
- `Invalid query. When querying a collection group and ordering by ` +
807
- `FieldPath.documentId(), the value passed to ${
808
- usesFunctionalApi ( ) ? 'startAt' : 'Query.startAt'
809
- } () must result in a valid document path, but 'foo' is not because ` +
810
- `it contains an odd number of segments.`
786
+ 'Invalid query. When querying a collection group and ordering by ' +
787
+ 'FieldPath.documentId(), the value passed to Query.startAt() ' +
788
+ "must result in a valid document path, but 'foo' is not because " +
789
+ 'it contains an odd number of segments.'
811
790
) ;
812
791
}
813
792
) ;
@@ -1287,21 +1266,12 @@ apiDescribe('Validation:', (persistence: boolean) => {
1287
1266
1288
1267
validationIt ( persistence , 'cannot pass undefined as a field value' , db => {
1289
1268
const collection = db . collection ( 'test' ) ;
1290
- if ( usesFunctionalApi ( ) ) {
1291
- expect ( ( ) => collection . where ( 'foo' , '==' , undefined ) ) . to . throw (
1292
- 'Function where() called with invalid data. Unsupported field value: undefined'
1293
- ) ;
1294
- expect ( ( ) => collection . orderBy ( 'foo' ) . startAt ( undefined ) ) . to . throw (
1295
- 'Function startAt() called with invalid data. Unsupported field value: undefined'
1296
- ) ;
1297
- } else {
1298
- expect ( ( ) => collection . where ( 'foo' , '==' , undefined ) ) . to . throw (
1299
- 'Function Query.where() called with invalid data. Unsupported field value: undefined'
1300
- ) ;
1301
- expect ( ( ) => collection . orderBy ( 'foo' ) . startAt ( undefined ) ) . to . throw (
1302
- 'Function Query.startAt() called with invalid data. Unsupported field value: undefined'
1303
- ) ;
1304
- }
1269
+ expect ( ( ) => collection . where ( 'foo' , '==' , undefined ) ) . to . throw (
1270
+ 'Function Query.where() called with invalid data. Unsupported field value: undefined'
1271
+ ) ;
1272
+ expect ( ( ) => collection . orderBy ( 'foo' ) . startAt ( undefined ) ) . to . throw (
1273
+ 'Function Query.startAt() called with invalid data. Unsupported field value: undefined'
1274
+ ) ;
1305
1275
} ) ;
1306
1276
} ) ;
1307
1277
} ) ;
0 commit comments