@@ -2059,7 +2059,7 @@ describe('countQuery()', () => {
2059
2059
2060
2060
it ( 'empty test collection count' , ( ) => {
2061
2061
return withTestCollection ( async coll => {
2062
- const countQuery_ = countQuery ( query ( coll ) ) ;
2062
+ const countQuery_ = countQuery ( coll ) ;
2063
2063
const snapshot = await getAggregate ( countQuery_ ) ;
2064
2064
expect ( snapshot . getCount ( ) ) . to . equal ( 0 ) ;
2065
2065
} ) ;
@@ -2071,8 +2071,8 @@ describe('countQuery()', () => {
2071
2071
{ author : 'authorA' , title : 'titleB' } ,
2072
2072
{ author : 'authorB' , title : 'titleC' }
2073
2073
] ;
2074
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2075
- const countQuery_ = countQuery ( query ( collection ) ) ;
2074
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2075
+ const countQuery_ = countQuery ( coll ) ;
2076
2076
const snapshot = await getAggregate ( countQuery_ ) ;
2077
2077
expect ( snapshot . getCount ( ) ) . to . equal ( 3 ) ;
2078
2078
} ) ;
@@ -2084,8 +2084,8 @@ describe('countQuery()', () => {
2084
2084
{ author : 'authorA' , title : 'titleB' } ,
2085
2085
{ author : 'authorB' , title : 'titleC' }
2086
2086
] ;
2087
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2088
- const query_ = query ( collection , where ( 'author' , '==' , 'authorA' ) ) ;
2087
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2088
+ const query_ = query ( coll , where ( 'author' , '==' , 'authorA' ) ) ;
2089
2089
const countQuery_ = countQuery ( query_ ) ;
2090
2090
const snapshot = await getAggregate ( countQuery_ ) ;
2091
2091
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
@@ -2098,12 +2098,8 @@ describe('countQuery()', () => {
2098
2098
{ author : 'authorA' , title : 'titleB' } ,
2099
2099
{ author : 'authorB' , title : 'titleC' }
2100
2100
] ;
2101
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2102
- const query_ = query (
2103
- collection ,
2104
- where ( 'author' , '==' , 'authorA' ) ,
2105
- limit ( 1 )
2106
- ) ;
2101
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2102
+ const query_ = query ( coll , where ( 'author' , '==' , 'authorA' ) , limit ( 1 ) ) ;
2107
2103
const countQuery_ = countQuery ( query_ ) ;
2108
2104
const snapshot = await getAggregate ( countQuery_ ) ;
2109
2105
expect ( snapshot . getCount ( ) ) . to . equal ( 1 ) ;
@@ -2116,12 +2112,8 @@ describe('countQuery()', () => {
2116
2112
{ author : 'authorA' , title : 'titleB' } ,
2117
2113
{ author : 'authorB' , title : 'titleC' }
2118
2114
] ;
2119
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2120
- const query_ = query (
2121
- collection ,
2122
- where ( 'author' , '==' , 'authorA' ) ,
2123
- limit ( 3 )
2124
- ) ;
2115
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2116
+ const query_ = query ( coll , where ( 'author' , '==' , 'authorA' ) , limit ( 3 ) ) ;
2125
2117
const countQuery_ = countQuery ( query_ ) ;
2126
2118
const snapshot = await getAggregate ( countQuery_ ) ;
2127
2119
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
@@ -2135,8 +2127,8 @@ describe('countQuery()', () => {
2135
2127
{ author : 'authorB' , title : null } ,
2136
2128
{ author : 'authorB' }
2137
2129
] ;
2138
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2139
- const query_ = query ( collection , orderBy ( 'title' ) ) ;
2130
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2131
+ const query_ = query ( coll , orderBy ( 'title' ) ) ;
2140
2132
const countQuery_ = countQuery ( query_ ) ;
2141
2133
const snapshot = await getAggregate ( countQuery_ ) ;
2142
2134
expect ( snapshot . getCount ( ) ) . to . equal ( 3 ) ;
@@ -2150,8 +2142,8 @@ describe('countQuery()', () => {
2150
2142
{ id : 2 , author : 'authorB' , title : 'titleC' } ,
2151
2143
{ id : null , author : 'authorB' , title : 'titleD' }
2152
2144
] ;
2153
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2154
- const query_ = query ( collection , orderBy ( 'id' ) , startAt ( 2 ) ) ;
2145
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2146
+ const query_ = query ( coll , orderBy ( 'id' ) , startAt ( 2 ) ) ;
2155
2147
const countQuery_ = countQuery ( query_ ) ;
2156
2148
const snapshot = await getAggregate ( countQuery_ ) ;
2157
2149
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
@@ -2165,8 +2157,8 @@ describe('countQuery()', () => {
2165
2157
{ id : 2 , author : 'authorB' , title : 'titleC' } ,
2166
2158
{ id : null , author : 'authorB' , title : 'titleD' }
2167
2159
] ;
2168
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2169
- const query_ = query ( collection , orderBy ( 'id' ) , startAfter ( 2 ) ) ;
2160
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2161
+ const query_ = query ( coll , orderBy ( 'id' ) , startAfter ( 2 ) ) ;
2170
2162
const countQuery_ = countQuery ( query_ ) ;
2171
2163
const snapshot = await getAggregate ( countQuery_ ) ;
2172
2164
expect ( snapshot . getCount ( ) ) . to . equal ( 1 ) ;
@@ -2180,8 +2172,8 @@ describe('countQuery()', () => {
2180
2172
{ id : 2 , author : 'authorB' , title : 'titleC' } ,
2181
2173
{ id : null , author : 'authorB' , title : 'titleD' }
2182
2174
] ;
2183
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2184
- const query_ = query ( collection , orderBy ( 'id' ) , startAt ( 1 ) , endAt ( 2 ) ) ;
2175
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2176
+ const query_ = query ( coll , orderBy ( 'id' ) , startAt ( 1 ) , endAt ( 2 ) ) ;
2185
2177
const countQuery_ = countQuery ( query_ ) ;
2186
2178
const snapshot = await getAggregate ( countQuery_ ) ;
2187
2179
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
@@ -2195,8 +2187,8 @@ describe('countQuery()', () => {
2195
2187
{ id : 2 , author : 'authorB' , title : 'titleC' } ,
2196
2188
{ id : null , author : 'authorB' , title : 'titleD' }
2197
2189
] ;
2198
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2199
- const query_ = query ( collection , orderBy ( 'id' ) , startAt ( 1 ) , endBefore ( 2 ) ) ;
2190
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2191
+ const query_ = query ( coll , orderBy ( 'id' ) , startAt ( 1 ) , endBefore ( 2 ) ) ;
2200
2192
const countQuery_ = countQuery ( query_ ) ;
2201
2193
const snapshot = await getAggregate ( countQuery_ ) ;
2202
2194
expect ( snapshot . getCount ( ) ) . to . equal ( 1 ) ;
@@ -2209,9 +2201,9 @@ describe('countQuery()', () => {
2209
2201
{ author : 'authorA' , title : 'titleB' } ,
2210
2202
{ author : 'authorB' , title : 'titleC' }
2211
2203
] ;
2212
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2204
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2213
2205
const query_ = query (
2214
- collection ,
2206
+ coll ,
2215
2207
where ( 'author' , '==' , 'authorA' )
2216
2208
) . withConverter ( postConverter ) ;
2217
2209
const countQuery_ = countQuery ( query_ ) ;
@@ -2247,9 +2239,9 @@ describe('countQuery()', () => {
2247
2239
{ author : 'authorA' , title : 'titleB' } ,
2248
2240
{ author : 'authorB' , title : 'titleC' }
2249
2241
] ;
2250
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2251
- const query1 = query ( collection , where ( 'author' , '==' , 'authorA' ) ) ;
2252
- const query2 = query ( collection , where ( 'author' , '==' , 'authorA' ) ) ;
2242
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2243
+ const query1 = query ( coll , where ( 'author' , '==' , 'authorA' ) ) ;
2244
+ const query2 = query ( coll , where ( 'author' , '==' , 'authorA' ) ) ;
2253
2245
const countQuery1 = countQuery ( query1 ) ;
2254
2246
const countQuery2 = countQuery ( query2 ) ;
2255
2247
expect ( aggregateQueryEqual ( countQuery1 , countQuery2 ) ) . to . be . true ;
@@ -2262,9 +2254,9 @@ describe('countQuery()', () => {
2262
2254
{ author : 'authorA' , title : 'titleB' } ,
2263
2255
{ author : 'authorB' , title : 'titleC' }
2264
2256
] ;
2265
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2266
- const query1 = query ( collection , where ( 'author' , '==' , 'authorA' ) ) ;
2267
- const query2 = query ( collection , where ( 'author' , '==' , 'authorB' ) ) ;
2257
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2258
+ const query1 = query ( coll , where ( 'author' , '==' , 'authorA' ) ) ;
2259
+ const query2 = query ( coll , where ( 'author' , '==' , 'authorB' ) ) ;
2268
2260
const countQuery1 = countQuery ( query1 ) ;
2269
2261
const countQuery2 = countQuery ( query2 ) ;
2270
2262
expect ( aggregateQueryEqual ( countQuery1 , countQuery2 ) ) . to . be . false ;
@@ -2277,9 +2269,9 @@ describe('countQuery()', () => {
2277
2269
{ author : 'authorA' , title : 'titleB' } ,
2278
2270
{ author : 'authorB' , title : 'titleC' }
2279
2271
] ;
2280
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2281
- const query1 = query ( collection , where ( 'author' , '==' , 'authorA' ) ) ;
2282
- const query2 = query ( collection , where ( 'author' , '==' , 'authorA' ) ) ;
2272
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2273
+ const query1 = query ( coll , where ( 'author' , '==' , 'authorA' ) ) ;
2274
+ const query2 = query ( coll , where ( 'author' , '==' , 'authorA' ) ) ;
2283
2275
const countQuery1A = countQuery ( query1 ) ;
2284
2276
const countQuery1B = countQuery ( query1 ) ;
2285
2277
const countQuery2 = countQuery ( query2 ) ;
@@ -2297,9 +2289,9 @@ describe('countQuery()', () => {
2297
2289
{ author : 'authorA' , title : 'titleB' } ,
2298
2290
{ author : 'authorB' , title : 'titleC' }
2299
2291
] ;
2300
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2301
- const query1 = query ( collection , where ( 'author' , '==' , 'authorA' ) ) ;
2302
- const query2 = query ( collection , where ( 'author' , '==' , 'authorB' ) ) ;
2292
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2293
+ const query1 = query ( coll , where ( 'author' , '==' , 'authorA' ) ) ;
2294
+ const query2 = query ( coll , where ( 'author' , '==' , 'authorB' ) ) ;
2303
2295
const countQuery1 = countQuery ( query1 ) ;
2304
2296
const countQuery2 = countQuery ( query2 ) ;
2305
2297
const snapshot1 = await getAggregate ( countQuery1 ) ;
@@ -2309,9 +2301,9 @@ describe('countQuery()', () => {
2309
2301
} ) ;
2310
2302
2311
2303
it ( 'count query on a terminated Firestore' , ( ) => {
2312
- return withTestCollection ( async collection => {
2313
- await terminate ( collection . firestore ) ;
2314
- const countQuery_ = countQuery ( query ( collection ) ) ;
2304
+ return withTestCollection ( async coll => {
2305
+ await terminate ( coll . firestore ) ;
2306
+ const countQuery_ = countQuery ( coll ) ;
2315
2307
expect ( ( ) => getAggregate ( countQuery_ ) ) . to . throw (
2316
2308
'The client has already been terminated.'
2317
2309
) ;
@@ -2324,10 +2316,10 @@ describe('countQuery()', () => {
2324
2316
{ author : 'authorA' , title : 'titleB' } ,
2325
2317
{ author : 'authorB' , title : 'titleC' }
2326
2318
] ;
2327
- return withTestCollectionAndInitialData ( testDocs , async collection => {
2328
- const countQuery_ = countQuery ( query ( collection ) ) ;
2319
+ return withTestCollectionAndInitialData ( testDocs , async coll => {
2320
+ const countQuery_ = countQuery ( coll ) ;
2329
2321
const promise = getAggregate ( countQuery_ ) ;
2330
- await terminate ( collection . firestore ) ;
2322
+ await terminate ( coll . firestore ) ;
2331
2323
const snapshot = await promise ;
2332
2324
expect ( snapshot . getCount ( ) ) . to . equal ( 3 ) ;
2333
2325
} ) ;
0 commit comments