@@ -2069,118 +2069,118 @@ describe('countQuery()', () => {
2069
2069
{ key : 'c' , value : 'Cooper' }
2070
2070
] ;
2071
2071
2072
- it ( 'empty collection count equals to 0 ', ( ) => {
2072
+ it . only ( 'AggregateQuery and AggregateQuerySnapshot inherits the original query ', ( ) => {
2073
2073
return withTestCollection ( async coll => {
2074
- const countQuery_ = countQuery ( query ( coll ) ) ;
2074
+ const query_ = query ( coll ) ;
2075
+
2076
+ const countQuery_ = countQuery ( query_ ) ;
2075
2077
expect ( countQuery_ . type ) . to . equal ( 'AggregateQuery' ) ;
2078
+ expect ( countQuery_ . query ) . to . equal ( query_ ) ;
2079
+
2080
+ const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2081
+ expect ( snapshot . query . query ) . to . equal ( query_ ) ;
2082
+ } ) ;
2083
+ } ) ;
2084
+
2085
+ it . only ( 'empty collection count equals to 0' , ( ) => {
2086
+ return withTestCollection ( async coll => {
2087
+ const countQuery_ = countQuery ( query ( coll ) ) ;
2076
2088
2077
2089
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2078
2090
expect ( snapshot . getCount ( ) ) . to . equal ( 0 ) ;
2079
2091
} ) ;
2080
2092
} ) ;
2081
2093
2082
- it ( 'test collection count equals to 6' , ( ) => {
2094
+ it . only ( 'test collection count equals to 6' , ( ) => {
2083
2095
return withTestCollectionAndInitialData ( testDocs , async collection => {
2084
2096
const countQuery_ = countQuery ( query ( collection ) ) ;
2085
2097
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2086
2098
expect ( snapshot . getCount ( ) ) . to . equal ( 6 ) ;
2087
2099
} ) ;
2088
2100
} ) ;
2089
2101
2090
- it ( 'test collection count with filter' , ( ) => {
2102
+ it . only ( 'test collection count with filter' , ( ) => {
2091
2103
return withTestCollectionAndInitialData ( testDocs , async collection => {
2092
2104
const query_ = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2093
-
2094
2105
const countQuery_ = countQuery ( query_ ) ;
2095
2106
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2096
2107
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
2097
2108
} ) ;
2098
2109
} ) ;
2099
2110
2100
- it ( 'test collection count with filter effected by small limit' , ( ) => {
2101
- // limit that is less that the actual count would work like count up_to.
2111
+ it . only ( 'test collection count with filter and a small limit size' , ( ) => {
2102
2112
return withTestCollectionAndInitialData ( testDocs , async collection => {
2103
2113
const query_ = query ( collection , where ( 'key' , '==' , 'a' ) , limit ( 1 ) ) ;
2104
-
2105
2114
const countQuery_ = countQuery ( query_ ) ;
2106
2115
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2107
2116
expect ( snapshot . getCount ( ) ) . to . equal ( 1 ) ;
2108
2117
} ) ;
2109
2118
} ) ;
2110
2119
2111
- it ( 'test collection count with filter not effected by large limit' , ( ) => {
2112
- //limit that is larger than actual count wouldn't impact the return value
2120
+ it . only ( 'test collection count with filter and a large limit size' , ( ) => {
2113
2121
return withTestCollectionAndInitialData ( testDocs , async collection => {
2114
2122
const query_ = query ( collection , where ( 'key' , '==' , 'a' ) , limit ( 3 ) ) ;
2115
-
2116
2123
const countQuery_ = countQuery ( query_ ) ;
2117
2124
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2118
2125
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
2119
2126
} ) ;
2120
2127
} ) ;
2121
2128
2122
- it ( 'test collection count with converter on query' , ( ) => {
2123
- //testing out the converter impact on the AggregateQuery type
2129
+ it . only ( 'test collection count with converter on query' , ( ) => {
2124
2130
return withTestCollectionAndInitialData ( testDocs , async collection => {
2125
2131
const query_ = query ( collection , where ( 'key' , '==' , 'a' ) ) . withConverter (
2126
2132
converter
2127
2133
) ;
2128
-
2129
2134
const countQuery_ = countQuery ( query_ ) ;
2130
2135
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2131
2136
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
2132
2137
} ) ;
2133
2138
} ) ;
2134
2139
2135
- it ( 'test collection count with converter on collection' , ( ) => {
2136
- //testing out the converter impact on the AggregateQuery type
2140
+ it . only ( 'aggregateQueryEqual returns true on same queries' , ( ) => {
2137
2141
return withTestCollectionAndInitialData ( testDocs , async collection => {
2138
- const ref = collection . withConverter ( converter ) ;
2139
- const query_ = query ( ref , where ( 'key' , '==' , 'a' ) ) ;
2140
-
2141
- const countQuery_ = countQuery ( query_ ) ;
2142
- const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2143
- expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
2142
+ const query1 = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2143
+ const query2 = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2144
+ const countQuery1 = countQuery ( query1 ) ;
2145
+ const countQuery2 = countQuery ( query2 ) ;
2146
+ expect ( aggregateQueryEqual ( countQuery1 , countQuery2 ) ) . to . be . true ;
2144
2147
} ) ;
2145
2148
} ) ;
2146
2149
2147
- it ( 'aggregateQueryEqual returns true on same queries' , ( ) => {
2150
+ it . only ( 'aggregateQueryEqual returns false on different queries' , ( ) => {
2148
2151
return withTestCollectionAndInitialData ( testDocs , async collection => {
2149
- const query_1 = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2150
- const query_2 = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2151
-
2152
- const countQuery_1 = countQuery ( query_1 ) ;
2153
- const countQuery_2 = countQuery ( query_2 ) ;
2154
- expect ( aggregateQueryEqual ( countQuery_1 , countQuery_2 ) ) . to . be . true ;
2152
+ const query1 = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2153
+ const query2 = query ( collection , where ( 'key' , '!=' , 'a' ) ) ;
2154
+ const countQuery1 = countQuery ( query1 ) ;
2155
+ const countQuery2 = countQuery ( query2 ) ;
2156
+ expect ( aggregateQueryEqual ( countQuery1 , countQuery2 ) ) . to . be . false ;
2155
2157
} ) ;
2156
2158
} ) ;
2157
-
2158
- it ( 'aggregateQueryEqual returns false on different queries' , ( ) => {
2159
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2160
- const query_1 = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2161
- const query_2 = query ( collection , where ( 'key' , '!=' , 'a' ) ) ;
2162
2159
2163
- const countQuery_1 = countQuery ( query_1 ) ;
2164
- const countQuery_2 = countQuery ( query_2 ) ;
2165
- expect ( aggregateQueryEqual ( countQuery_1 , countQuery_2 ) ) . to . be . false ;
2160
+ it . only ( 'aggregateQuerySnapshotEqual returns true on same queries' , ( ) => {
2161
+ return withTestCollectionAndInitialData ( testDocs , async collection => {
2162
+ const query1 = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2163
+ const query2 = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2164
+ const countQuery1A = countQuery ( query1 ) ;
2165
+ const countQuery1B = countQuery ( query1 ) ;
2166
+ const countQuery2 = countQuery ( query2 ) ;
2167
+ const snapshot1A = await getAggregateFromServerDirect ( countQuery1A ) ;
2168
+ const snapshot1B = await getAggregateFromServerDirect ( countQuery1B ) ;
2169
+ const snapshot2 = await getAggregateFromServerDirect ( countQuery2 ) ;
2170
+ expect ( aggregateQuerySnapshotEqual ( snapshot1A , snapshot1B ) ) . to . be . true ;
2171
+ expect ( aggregateQuerySnapshotEqual ( snapshot1A , snapshot2 ) ) . to . be . true ;
2166
2172
} ) ;
2167
2173
} ) ;
2168
2174
2169
- it ( 'aggregateQuerySnapshotEqual returns true on same queries' , ( ) => {
2175
+ it . only ( 'aggregateQuerySnapshotEqual returns false on different queries' , ( ) => {
2170
2176
return withTestCollectionAndInitialData ( testDocs , async collection => {
2171
- const query_original = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2172
- const query_copy = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2173
-
2174
- const countQuery_original_1 = countQuery ( query_original ) ;
2175
- const countQuery_original_2 = countQuery ( query_original ) ;
2176
- const countQuery_copy = countQuery ( query_copy ) ;
2177
-
2178
- const snapshot_original_1 = await getAggregateFromServerDirect ( countQuery_original_1 ) ;
2179
- const snapshot_original_2 = await getAggregateFromServerDirect ( countQuery_original_2 ) ;
2180
- const snapshot_copy = await getAggregateFromServerDirect ( countQuery_copy ) ;
2181
-
2182
- expect ( aggregateQuerySnapshotEqual ( snapshot_original_1 , snapshot_original_2 ) ) . to . be . true ;
2183
- expect ( aggregateQuerySnapshotEqual ( snapshot_original_1 , snapshot_copy ) ) . to . be . true ;
2177
+ const query1 = query ( collection , where ( 'key' , '==' , 'a' ) ) ;
2178
+ const query2 = query ( collection , where ( 'key' , '==' , 'b' ) ) ;
2179
+ const countQuery1 = countQuery ( query1 ) ;
2180
+ const countQuery2 = countQuery ( query2 ) ;
2181
+ const snapshot1 = await getAggregateFromServerDirect ( countQuery1 ) ;
2182
+ const snapshot2 = await getAggregateFromServerDirect ( countQuery2 ) ;
2183
+ expect ( aggregateQuerySnapshotEqual ( snapshot1 , snapshot2 ) ) . to . be . false ;
2184
2184
} ) ;
2185
2185
} ) ;
2186
2186
} ) ;
0 commit comments