@@ -62,7 +62,16 @@ import {
62
62
increment ,
63
63
serverTimestamp ,
64
64
arrayUnion ,
65
- arrayRemove
65
+ arrayRemove ,
66
+ orderBy ,
67
+ startAfter ,
68
+ query ,
69
+ limit ,
70
+ endAt ,
71
+ endBefore ,
72
+ startAt ,
73
+ limitToLast ,
74
+ where
66
75
} from '..' ;
67
76
import {
68
77
DEFAULT_PROJECT_ID ,
@@ -764,8 +773,8 @@ describe('Query', () => {
764
773
return withTestCollectionAndInitialData (
765
774
[ { foo : 1 } , { foo : 2 } ] ,
766
775
async collRef => {
767
- const query = collRef . where ( 'foo' , '==' , 1 ) ;
768
- const result = await getQuery ( query ) ;
776
+ const query1 = query ( collRef , where ( 'foo' , '==' , 1 ) ) ;
777
+ const result = await getQuery ( query1 ) ;
769
778
verifyResults ( result , { foo : 1 } ) ;
770
779
}
771
780
) ;
@@ -775,8 +784,8 @@ describe('Query', () => {
775
784
return withTestCollectionAndInitialData (
776
785
[ { foo : 1 } , { foo : 2 } ] ,
777
786
async collRef => {
778
- const query = collRef . where ( new FieldPath ( 'foo' ) , '==' , 1 ) ;
779
- const result = await getQuery ( query ) ;
787
+ const query1 = query ( collRef , where ( new FieldPath ( 'foo' ) , '==' , 1 ) ) ;
788
+ const result = await getQuery ( query1 ) ;
780
789
verifyResults ( result , { foo : 1 } ) ;
781
790
}
782
791
) ;
@@ -786,8 +795,8 @@ describe('Query', () => {
786
795
return withTestCollectionAndInitialData (
787
796
[ { foo : 1 } , { foo : 2 } ] ,
788
797
async collRef => {
789
- const query = collRef . orderBy ( 'foo' ) ;
790
- const result = await getQuery ( query ) ;
798
+ const query1 = query ( collRef , orderBy ( 'foo' ) ) ;
799
+ const result = await getQuery ( query1 ) ;
791
800
verifyResults ( result , { foo : 1 } , { foo : 2 } ) ;
792
801
}
793
802
) ;
@@ -797,8 +806,8 @@ describe('Query', () => {
797
806
return withTestCollectionAndInitialData (
798
807
[ { foo : 1 } , { foo : 2 } ] ,
799
808
async collRef => {
800
- const query = collRef . orderBy ( 'foo' , 'asc' ) ;
801
- const result = await getQuery ( query ) ;
809
+ const query1 = query ( collRef , orderBy ( 'foo' , 'asc' ) ) ;
810
+ const result = await getQuery ( query1 ) ;
802
811
verifyResults ( result , { foo : 1 } , { foo : 2 } ) ;
803
812
}
804
813
) ;
@@ -808,8 +817,8 @@ describe('Query', () => {
808
817
return withTestCollectionAndInitialData (
809
818
[ { foo : 1 } , { foo : 2 } ] ,
810
819
async collRef => {
811
- const query = collRef . orderBy ( 'foo' , 'desc' ) ;
812
- const result = await getQuery ( query ) ;
820
+ const query1 = query ( collRef , orderBy ( 'foo' , 'desc' ) ) ;
821
+ const result = await getQuery ( query1 ) ;
813
822
verifyResults ( result , { foo : 2 } , { foo : 1 } ) ;
814
823
}
815
824
) ;
@@ -819,8 +828,8 @@ describe('Query', () => {
819
828
return withTestCollectionAndInitialData (
820
829
[ { foo : 1 } , { foo : 2 } ] ,
821
830
async collRef => {
822
- const query = collRef . orderBy ( 'foo' ) . limit ( 1 ) ;
823
- const result = await getQuery ( query ) ;
831
+ const query1 = query ( collRef , orderBy ( 'foo' ) , limit ( 1 ) ) ;
832
+ const result = await getQuery ( query1 ) ;
824
833
verifyResults ( result , { foo : 1 } ) ;
825
834
}
826
835
) ;
@@ -830,8 +839,8 @@ describe('Query', () => {
830
839
return withTestCollectionAndInitialData (
831
840
[ { foo : 1 } , { foo : 2 } , { foo : 3 } ] ,
832
841
async collRef => {
833
- const query = collRef . orderBy ( 'foo' ) . limitToLast ( 2 ) ;
834
- const result = await getQuery ( query ) ;
842
+ const query1 = query ( collRef , orderBy ( 'foo' ) , limitToLast ( 2 ) ) ;
843
+ const result = await getQuery ( query1 ) ;
835
844
verifyResults ( result , { foo : 2 } , { foo : 3 } ) ;
836
845
}
837
846
) ;
@@ -841,8 +850,8 @@ describe('Query', () => {
841
850
return withTestCollectionAndInitialData (
842
851
[ { foo : 1 } , { foo : 2 } ] ,
843
852
async collRef => {
844
- const query = collRef . orderBy ( 'foo' ) . startAt ( 2 ) ;
845
- const result = await getQuery ( query ) ;
853
+ const query1 = query ( collRef , orderBy ( 'foo' ) , startAt ( 2 ) ) ;
854
+ const result = await getQuery ( query1 ) ;
846
855
verifyResults ( result , { foo : 2 } ) ;
847
856
}
848
857
) ;
@@ -852,8 +861,8 @@ describe('Query', () => {
852
861
return withTestCollectionAndInitialData (
853
862
[ { foo : 1 } , { foo : 2 } ] ,
854
863
async collRef => {
855
- const query = collRef . orderBy ( 'foo' ) . startAfter ( 1 ) ;
856
- const result = await getQuery ( query ) ;
864
+ const query1 = query ( collRef , orderBy ( 'foo' ) , startAfter ( 1 ) ) ;
865
+ const result = await getQuery ( query1 ) ;
857
866
verifyResults ( result , { foo : 2 } ) ;
858
867
}
859
868
) ;
@@ -863,8 +872,8 @@ describe('Query', () => {
863
872
return withTestCollectionAndInitialData (
864
873
[ { foo : 1 } , { foo : 2 } ] ,
865
874
async collRef => {
866
- const query = collRef . orderBy ( 'foo' ) . endAt ( 1 ) ;
867
- const result = await getQuery ( query ) ;
875
+ const query1 = query ( collRef , orderBy ( 'foo' ) , endAt ( 1 ) ) ;
876
+ const result = await getQuery ( query1 ) ;
868
877
verifyResults ( result , { foo : 1 } ) ;
869
878
}
870
879
) ;
@@ -874,8 +883,8 @@ describe('Query', () => {
874
883
return withTestCollectionAndInitialData (
875
884
[ { foo : 1 } , { foo : 2 } ] ,
876
885
async collRef => {
877
- const query = collRef . orderBy ( 'foo' ) . endBefore ( 2 ) ;
878
- const result = await getQuery ( query ) ;
886
+ const query1 = query ( collRef , orderBy ( 'foo' ) , endBefore ( 2 ) ) ;
887
+ const result = await getQuery ( query1 ) ;
879
888
verifyResults ( result , { foo : 1 } ) ;
880
889
}
881
890
) ;
@@ -885,13 +894,13 @@ describe('Query', () => {
885
894
return withTestCollectionAndInitialData (
886
895
[ { foo : 1 } , { foo : 2 } ] ,
887
896
async collRef => {
888
- let query = collRef . orderBy ( 'foo' ) . limit ( 1 ) ;
889
- let result = await getQuery ( query ) ;
897
+ let query1 = query ( collRef , orderBy ( 'foo' ) , limit ( 1 ) ) ;
898
+ let result = await getQuery ( query1 ) ;
890
899
verifyResults ( result , { foo : 1 } ) ;
891
900
892
901
// Pass the document snapshot from the previous result
893
- query = query . startAfter ( result . docs [ 0 ] ) ;
894
- result = await getQuery ( query ) ;
902
+ query1 = query ( query1 , startAfter ( result . docs [ 0 ] ) ) ;
903
+ result = await getQuery ( query1 ) ;
895
904
verifyResults ( result , { foo : 2 } ) ;
896
905
}
897
906
) ;
@@ -912,8 +921,8 @@ describe('Query', () => {
912
921
await setDoc ( fooDoc , { foo : 1 } ) ;
913
922
await setDoc ( barDoc , { bar : 1 } ) ;
914
923
915
- const query = collectionGroup ( collRef . firestore , collectionGroupId ) ;
916
- const result = await getQuery ( query ) ;
924
+ const query1 = collectionGroup ( collRef . firestore , collectionGroupId ) ;
925
+ const result = await getQuery < firestore . DocumentData > ( query1 ) ;
917
926
918
927
verifyResults ( result , { bar : 1 } , { foo : 1 } ) ;
919
928
} ) ;
@@ -976,10 +985,10 @@ describe('equality', () => {
976
985
return withTestCollectionAndInitialData (
977
986
[ { foo : 1 } , { foo : 2 } ] ,
978
987
async collRef => {
979
- const query1a = collRef . orderBy ( 'foo' ) ;
980
- const query1b = collRef . orderBy ( 'foo' , 'asc' ) ;
981
- const query2 = collRef . orderBy ( 'foo' , 'desc' ) ;
982
- const query3 = collection ( collRef , 'a/b' ) . orderBy ( 'foo' ) ;
988
+ const query1a = query ( collRef , orderBy ( 'foo' ) ) ;
989
+ const query1b = query ( collRef , orderBy ( 'foo' , 'asc' ) ) ;
990
+ const query2 = query ( collRef , orderBy ( 'foo' , 'desc' ) ) ;
991
+ const query3 = query ( collection ( collRef , 'a/b' ) , orderBy ( 'foo' ) ) ;
983
992
984
993
expect ( queryEqual ( query1a , query1b ) ) . to . be . true ;
985
994
expect ( queryEqual ( query1a , query2 ) ) . to . be . false ;
@@ -992,9 +1001,9 @@ describe('equality', () => {
992
1001
return withTestCollectionAndInitialData (
993
1002
[ { foo : 1 } , { foo : 2 } ] ,
994
1003
async collRef => {
995
- const query1a = collRef . limit ( 10 ) ;
996
- const query1b = collRef . limit ( 10 ) ;
997
- const query2 = collRef . limit ( 100 ) ;
1004
+ const query1a = query ( collRef , limit ( 10 ) ) ;
1005
+ const query1b = query ( collRef , limit ( 10 ) ) ;
1006
+ const query2 = query ( collRef , limit ( 100 ) ) ;
998
1007
999
1008
const snap1a = await getQuery ( query1a ) ;
1000
1009
const snap1b = await getQuery ( query1b ) ;
0 commit comments