17
17
18
18
import { expect } from 'chai' ;
19
19
20
- import { ListenerDataSource as Source } from '../../../src/core/event_manager' ;
21
20
import { EventsAccumulator } from '../util/events_accumulator' ;
22
21
import {
23
22
addDoc ,
@@ -59,7 +58,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
59
58
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
60
59
const unsubscribe = onSnapshot (
61
60
coll ,
62
- { source : Source . Cache } ,
61
+ { source : 'cache' } ,
63
62
storeEvent . storeEvent
64
63
) ;
65
64
@@ -83,7 +82,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
83
82
const storeEvent = new EventsAccumulator < DocumentSnapshot > ( ) ;
84
83
const unsubscribe = onSnapshot (
85
84
docRef ,
86
- { source : Source . Cache } ,
85
+ { source : 'cache' } ,
87
86
storeEvent . storeEvent
88
87
) ;
89
88
@@ -107,7 +106,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
107
106
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
108
107
const unsubscribe = onSnapshot (
109
108
coll ,
110
- { includeMetadataChanges : true , source : Source . Cache } ,
109
+ { includeMetadataChanges : true , source : 'cache' } ,
111
110
storeEvent . storeEvent
112
111
) ;
113
112
@@ -139,13 +138,13 @@ apiDescribe('Snapshot Listener source options ', persistence => {
139
138
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
140
139
const unsubscribe1 = onSnapshot (
141
140
testQuery ,
142
- { source : Source . Cache } ,
141
+ { source : 'cache' } ,
143
142
storeEvent . storeEvent
144
143
) ;
145
144
146
145
const unsubscribe2 = onSnapshot (
147
146
testQuery ,
148
- { source : Source . Cache } ,
147
+ { source : 'cache' } ,
149
148
storeEvent . storeEvent
150
149
) ;
151
150
@@ -207,15 +206,15 @@ apiDescribe('Snapshot Listener source options ', persistence => {
207
206
const storeLimitEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
208
207
let limitUnlisten = onSnapshot (
209
208
query ( coll , orderBy ( 'sort' , 'asc' ) , limit ( 2 ) ) ,
210
- { source : Source . Cache } ,
209
+ { source : 'cache' } ,
211
210
storeLimitEvent . storeEvent
212
211
) ;
213
212
214
213
// Setup mirroring `limitToLast` query
215
214
const storeLimitToLastEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
216
215
let limitToLastUnlisten = onSnapshot (
217
216
query ( coll , orderBy ( 'sort' , 'desc' ) , limitToLast ( 2 ) ) ,
218
- { source : Source . Cache } ,
217
+ { source : 'cache' } ,
219
218
storeLimitToLastEvent . storeEvent
220
219
) ;
221
220
@@ -235,7 +234,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
235
234
limitUnlisten ( ) ;
236
235
limitUnlisten = onSnapshot (
237
236
query ( coll , orderBy ( 'sort' , 'asc' ) , limit ( 2 ) ) ,
238
- { source : Source . Cache } ,
237
+ { source : 'cache' } ,
239
238
storeLimitEvent . storeEvent
240
239
) ;
241
240
snapshot = await storeLimitEvent . awaitEvent ( ) ;
@@ -269,7 +268,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
269
268
await updateDoc ( doc ( coll , 'a' ) , { k : 'a' , sort : - 2 } ) ;
270
269
limitToLastUnlisten = onSnapshot (
271
270
query ( coll , orderBy ( 'sort' , 'desc' ) , limitToLast ( 2 ) ) ,
272
- { source : Source . Cache } ,
271
+ { source : 'cache' } ,
273
272
storeLimitToLastEvent . storeEvent
274
273
) ;
275
274
@@ -320,7 +319,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
320
319
const storeCacheEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
321
320
const cacheUnlisten = onSnapshot (
322
321
testQuery ,
323
- { source : Source . Cache } ,
322
+ { source : 'cache' } ,
324
323
storeCacheEvent . storeEvent
325
324
) ;
326
325
snapshot = await storeCacheEvent . awaitEvent ( ) ;
@@ -352,7 +351,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
352
351
353
352
const cacheUnlisten = onSnapshot (
354
353
testQuery ,
355
- { source : Source . Cache } ,
354
+ { source : 'cache' } ,
356
355
storeCacheEvent . storeEvent
357
356
) ;
358
357
let snapshot = await storeCacheEvent . awaitEvent ( ) ;
@@ -401,7 +400,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
401
400
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
402
401
const unsubscribe = onSnapshot (
403
402
testQuery ,
404
- { includeMetadataChanges : true , source : Source . Cache } ,
403
+ { includeMetadataChanges : true , source : 'cache' } ,
405
404
storeEvent . storeEvent
406
405
) ;
407
406
@@ -443,7 +442,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
443
442
const storeCacheEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
444
443
const cacheUnlisten = onSnapshot (
445
444
testQuery ,
446
- { includeMetadataChanges : true , source : Source . Cache } ,
445
+ { includeMetadataChanges : true , source : 'cache' } ,
447
446
storeCacheEvent . storeEvent
448
447
) ;
449
448
let snapshot = await storeCacheEvent . awaitEvent ( ) ;
@@ -523,7 +522,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
523
522
const storeCacheEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
524
523
const cacheUnlisten = onSnapshot (
525
524
testQuery ,
526
- { source : Source . Cache } ,
525
+ { source : 'cache' } ,
527
526
storeCacheEvent . storeEvent
528
527
) ;
529
528
await storeCacheEvent . awaitEvent ( ) ;
@@ -568,7 +567,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
568
567
const storeCacheEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
569
568
const cacheUnlisten = onSnapshot (
570
569
testQuery ,
571
- { source : Source . Cache } ,
570
+ { source : 'cache' } ,
572
571
storeCacheEvent . storeEvent
573
572
) ;
574
573
await storeCacheEvent . awaitEvent ( ) ;
@@ -617,7 +616,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
617
616
const storeCacheEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
618
617
let cacheUnlisten = onSnapshot (
619
618
testQuery ,
620
- { source : Source . Cache } ,
619
+ { source : 'cache' } ,
621
620
storeCacheEvent . storeEvent
622
621
) ;
623
622
snapshot = await storeCacheEvent . awaitEvent ( ) ;
@@ -651,7 +650,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
651
650
652
651
cacheUnlisten = onSnapshot (
653
652
testQuery ,
654
- { source : Source . Cache } ,
653
+ { source : 'cache' } ,
655
654
storeCacheEvent . storeEvent
656
655
) ;
657
656
@@ -679,7 +678,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
679
678
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
680
679
const unsubscribe = onSnapshot (
681
680
testQuery ,
682
- { source : Source . Cache } ,
681
+ { source : 'cache' } ,
683
682
storeEvent . storeEvent
684
683
) ;
685
684
@@ -695,7 +694,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
695
694
expect ( toDataArray ( snapshot ) ) . to . deep . equal ( [ ] ) ; // Precondition check.
696
695
697
696
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
698
- onSnapshot ( coll , { source : Source . Cache } , storeEvent . storeEvent ) ;
697
+ onSnapshot ( coll , { source : 'cache' } , storeEvent . storeEvent ) ;
699
698
snapshot = await storeEvent . awaitEvent ( ) ;
700
699
expect ( snapshot . metadata . fromCache ) . to . be . true ;
701
700
expect ( toDataArray ( snapshot ) ) . to . deep . equal ( [ ] ) ;
@@ -707,7 +706,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
707
706
const accumulator = new EventsAccumulator < QuerySnapshot > ( ) ;
708
707
const unsubscribe = onSnapshot (
709
708
coll ,
710
- { source : Source . Cache } ,
709
+ { source : 'cache' } ,
711
710
accumulator . storeEvent
712
711
) ;
713
712
@@ -752,7 +751,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
752
751
const storeCacheEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
753
752
const cacheUnlisten = onSnapshot (
754
753
testQuery ,
755
- { source : Source . Cache } ,
754
+ { source : 'cache' } ,
756
755
storeCacheEvent . storeEvent
757
756
) ;
758
757
snapshot = await storeCacheEvent . awaitEvent ( ) ;
0 commit comments