@@ -2318,50 +2318,18 @@ describe('countQuery()', () => {
2318
2318
} ) ;
2319
2319
} ) ;
2320
2320
2321
- it . only ( 'terminate Firestore while calling count query' , ( ) => {
2321
+ it ( 'terminate Firestore while calling count query' , ( ) => {
2322
2322
const testDocs = [
2323
2323
{ author : 'authorA' , title : 'titleA' } ,
2324
2324
{ author : 'authorA' , title : 'titleB' } ,
2325
2325
{ author : 'authorB' , title : 'titleC' }
2326
2326
] ;
2327
2327
return withTestCollectionAndInitialData ( testDocs , async collection => {
2328
2328
const countQuery_ = countQuery ( query ( collection ) ) ;
2329
-
2330
- //This will pass
2331
- // const promise = getAggregateFromServerDirect(countQuery_)
2332
- // await terminate(collection.firestore)
2333
- // expect((await promise).getCount()).to.equal(3);
2334
-
2335
- //this will pass
2336
- // const [promise,voidResult] = await Promise.all([
2337
- // getAggregateFromServerDirect(countQuery_),
2338
- // terminate(collection.firestore),
2339
- // ])
2340
- // expect(promise.getCount()).to.equal(3);
2341
-
2342
- //if terminate comes first, it will throw error
2343
- // expect(() => Promise.all([
2344
- // terminate(collection.firestore),
2345
- // getAggregateFromServerDirect(countQuery_),
2346
- // ])).to.throw(
2347
- // 'The client has already been terminated.'
2348
- // );
2349
-
2350
- // not sure why, this is not getting to the "then" block
2351
- // and therefore it is not checking the "expect" at all
2352
- Promise . all ( [
2353
- getAggregateFromServerDirect ( countQuery_ ) ,
2354
- terminate ( collection . firestore )
2355
- ] )
2356
- . then ( ( [ promise , voidResult ] ) => {
2357
- console . log ( 'snapshot' , promise ) ;
2358
- expect ( promise . getCount ( ) ) . to . equal ( 100 ) ;
2359
- } )
2360
- . catch ( e => {
2361
- expect ( ( e as Error ) ?. message ) . to . equal (
2362
- 'The client has already been terminated.'
2363
- ) ;
2364
- } ) ;
2329
+ const promise = getAggregateFromServerDirect ( countQuery_ ) ;
2330
+ await terminate ( collection . firestore ) ;
2331
+ const snapshot = await promise ;
2332
+ expect ( snapshot . getCount ( ) ) . to . equal ( 3 ) ;
2365
2333
} ) ;
2366
2334
} ) ;
2367
2335
} ) ;
0 commit comments