16
16
*/
17
17
18
18
import { LimitType , queryWithLimit } from '../../../src/core/query' ;
19
- import { deletedDoc , doc , filter , orderBy , query } from '../../util/helpers' ;
19
+ import { doc , filter , orderBy , query } from '../../util/helpers' ;
20
20
21
21
import { bundleWithDocumentAndQuery } from './bundle_spec.test' ;
22
22
import { describeSpec , specTest } from './describe_spec' ;
@@ -28,30 +28,29 @@ describeSpec('Listens source options:', [], () => {
28
28
[ 'eager-gc' ] ,
29
29
'Explicitly tests eager GC behavior' ,
30
30
( ) => {
31
- const query_ = query ( 'collection' ) ;
31
+ const testQuery = query ( 'collection' ) ;
32
32
const docA = doc ( 'collection/a' , 0 , { key : 'a' } ) . setHasLocalMutations ( ) ;
33
33
return (
34
34
spec ( )
35
35
. userSets ( 'collection/a' , { key : 'a' } )
36
- . userListensToCache ( query_ )
37
- . expectEvents ( query_ , {
36
+ . userListensToCache ( testQuery )
37
+ . expectEvents ( testQuery , {
38
38
added : [ docA ] ,
39
39
hasPendingWrites : true ,
40
40
fromCache : true
41
41
} )
42
- . userUnlistensToCache ( query_ )
42
+ . userUnlistensToCache ( testQuery )
43
43
. writeAcks ( 'collection/a' , 1000 )
44
44
// Cache is empty as docA is GCed.
45
- . userListensToCache ( query_ )
46
- . expectEvents ( query_ , { added : [ ] , fromCache : true } )
45
+ . userListensToCache ( testQuery )
46
+ . expectEvents ( testQuery , { added : [ ] , fromCache : true } )
47
47
) ;
48
48
}
49
49
) ;
50
50
51
51
specTest (
52
52
'Documents are cleared when listen is removed.' ,
53
53
[ 'eager-gc' ] ,
54
- '' ,
55
54
( ) => {
56
55
const filteredQuery = query ( 'collection' , filter ( 'matches' , '==' , true ) ) ;
57
56
const unfilteredQuery = query ( 'collection' ) ;
@@ -91,42 +90,40 @@ describeSpec('Listens source options:', [], () => {
91
90
) ;
92
91
93
92
specTest ( "Doesn't include unknown documents in cached result" , [ ] , ( ) => {
94
- const query_ = query ( 'collection' ) ;
93
+ const testQuery = query ( 'collection' ) ;
95
94
const existingDoc = doc ( 'collection/exists' , 0 , {
96
95
key : 'a'
97
96
} ) . setHasLocalMutations ( ) ;
98
97
return spec ( )
99
98
. userSets ( 'collection/exists' , { key : 'a' } )
100
99
. userPatches ( 'collection/unknown' , { key : 'b' } )
101
- . userListensToCache ( query_ )
102
- . expectEvents ( query_ , {
100
+ . userListensToCache ( testQuery )
101
+ . expectEvents ( testQuery , {
103
102
added : [ existingDoc ] ,
104
103
fromCache : true ,
105
104
hasPendingWrites : true
106
105
} ) ;
107
106
} ) ;
108
107
109
108
specTest ( "Doesn't raise 'hasPendingWrites' for deletes" , [ ] , ( ) => {
110
- const query_ = query ( 'collection' ) ;
109
+ const testQuery = query ( 'collection' ) ;
111
110
const docA = doc ( 'collection/a' , 1000 , { key : 'a' } ) ;
112
111
113
112
return (
114
113
spec ( )
115
114
. ensureManualLruGC ( )
116
115
// Populate the cache first
117
- . userListens ( query_ )
118
- . watchAcksFull ( query_ , 1000 , docA )
119
- . expectEvents ( query_ , { added : [ docA ] } )
120
- . userUnlistens ( query_ )
121
- . watchRemoves ( query_ )
116
+ . userListens ( testQuery )
117
+ . watchAcksFull ( testQuery , 1000 , docA )
118
+ . expectEvents ( testQuery , { added : [ docA ] } )
119
+ . userUnlistens ( testQuery )
120
+ . watchRemoves ( testQuery )
122
121
// Listen to cache
123
- . userListensToCache ( query_ )
124
- . expectEvents ( query_ , { added : [ docA ] , fromCache : true } )
122
+ . userListensToCache ( testQuery )
123
+ . expectEvents ( testQuery , { added : [ docA ] , fromCache : true } )
125
124
. userDeletes ( 'collection/a' )
126
- . expectEvents ( query_ , { removed : [ docA ] , fromCache : true } )
125
+ . expectEvents ( testQuery , { removed : [ docA ] , fromCache : true } )
127
126
. writeAcks ( 'collection/a' , 2000 )
128
- . watchSends ( { affects : [ query_ ] } , deletedDoc ( 'collection/a' , 2000 ) )
129
- . watchSnapshots ( 2000 )
130
127
) ;
131
128
} ) ;
132
129
@@ -554,7 +551,7 @@ describeSpec('Listens source options:', [], () => {
554
551
) ;
555
552
556
553
specTest (
557
- 'Query is executed by primary client even if it only includes listeners sourced from cache' ,
554
+ 'Query is executed by primary client even if primary client only has listeners sourced from cache' ,
558
555
[ 'multi-client' ] ,
559
556
( ) => {
560
557
const query1 = query ( 'collection' ) ;
0 commit comments