Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
milaGGL committed Mar 11, 2024
1 parent 0172b64 commit a340dd6
Showing 1 changed file with 21 additions and 22 deletions.
Expand Up @@ -17,7 +17,6 @@

import { expect } from 'chai';

import { ListenerDataSource as Source } from '../../../src/core/event_manager';
import { EventsAccumulator } from '../util/events_accumulator';
import {
addDoc,
Expand Down Expand Up @@ -59,7 +58,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeEvent = new EventsAccumulator<QuerySnapshot>();
const unsubscribe = onSnapshot(
coll,
{ source: Source.Cache },
{ source: 'cache' },
storeEvent.storeEvent
);

Expand All @@ -83,7 +82,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeEvent = new EventsAccumulator<DocumentSnapshot>();
const unsubscribe = onSnapshot(
docRef,
{ source: Source.Cache },
{ source: 'cache' },
storeEvent.storeEvent
);

Expand All @@ -107,7 +106,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeEvent = new EventsAccumulator<QuerySnapshot>();
const unsubscribe = onSnapshot(
coll,
{ includeMetadataChanges: true, source: Source.Cache },
{ includeMetadataChanges: true, source: 'cache' },
storeEvent.storeEvent
);

Expand Down Expand Up @@ -139,13 +138,13 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeEvent = new EventsAccumulator<QuerySnapshot>();
const unsubscribe1 = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeEvent.storeEvent
);

const unsubscribe2 = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeEvent.storeEvent
);

Expand Down Expand Up @@ -207,15 +206,15 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeLimitEvent = new EventsAccumulator<QuerySnapshot>();
let limitUnlisten = onSnapshot(
query(coll, orderBy('sort', 'asc'), limit(2)),
{ source: Source.Cache },
{ source: 'cache' },
storeLimitEvent.storeEvent
);

// Setup mirroring `limitToLast` query
const storeLimitToLastEvent = new EventsAccumulator<QuerySnapshot>();
let limitToLastUnlisten = onSnapshot(
query(coll, orderBy('sort', 'desc'), limitToLast(2)),
{ source: Source.Cache },
{ source: 'cache' },
storeLimitToLastEvent.storeEvent
);

Expand All @@ -235,7 +234,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
limitUnlisten();
limitUnlisten = onSnapshot(
query(coll, orderBy('sort', 'asc'), limit(2)),
{ source: Source.Cache },
{ source: 'cache' },
storeLimitEvent.storeEvent
);
snapshot = await storeLimitEvent.awaitEvent();
Expand Down Expand Up @@ -269,7 +268,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
await updateDoc(doc(coll, 'a'), { k: 'a', sort: -2 });
limitToLastUnlisten = onSnapshot(
query(coll, orderBy('sort', 'desc'), limitToLast(2)),
{ source: Source.Cache },
{ source: 'cache' },
storeLimitToLastEvent.storeEvent
);

Expand Down Expand Up @@ -320,7 +319,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeCacheEvent = new EventsAccumulator<QuerySnapshot>();
const cacheUnlisten = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeCacheEvent.storeEvent
);
snapshot = await storeCacheEvent.awaitEvent();
Expand Down Expand Up @@ -352,7 +351,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {

const cacheUnlisten = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeCacheEvent.storeEvent
);
let snapshot = await storeCacheEvent.awaitEvent();
Expand Down Expand Up @@ -401,7 +400,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeEvent = new EventsAccumulator<QuerySnapshot>();
const unsubscribe = onSnapshot(
testQuery,
{ includeMetadataChanges: true, source: Source.Cache },
{ includeMetadataChanges: true, source: 'cache' },
storeEvent.storeEvent
);

Expand Down Expand Up @@ -443,7 +442,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeCacheEvent = new EventsAccumulator<QuerySnapshot>();
const cacheUnlisten = onSnapshot(
testQuery,
{ includeMetadataChanges: true, source: Source.Cache },
{ includeMetadataChanges: true, source: 'cache' },
storeCacheEvent.storeEvent
);
let snapshot = await storeCacheEvent.awaitEvent();
Expand Down Expand Up @@ -523,7 +522,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeCacheEvent = new EventsAccumulator<QuerySnapshot>();
const cacheUnlisten = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeCacheEvent.storeEvent
);
await storeCacheEvent.awaitEvent();
Expand Down Expand Up @@ -568,7 +567,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeCacheEvent = new EventsAccumulator<QuerySnapshot>();
const cacheUnlisten = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeCacheEvent.storeEvent
);
await storeCacheEvent.awaitEvent();
Expand Down Expand Up @@ -617,7 +616,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeCacheEvent = new EventsAccumulator<QuerySnapshot>();
let cacheUnlisten = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeCacheEvent.storeEvent
);
snapshot = await storeCacheEvent.awaitEvent();
Expand Down Expand Up @@ -651,7 +650,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {

cacheUnlisten = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeCacheEvent.storeEvent
);

Expand Down Expand Up @@ -679,7 +678,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeEvent = new EventsAccumulator<QuerySnapshot>();
const unsubscribe = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeEvent.storeEvent
);

Expand All @@ -695,7 +694,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
expect(toDataArray(snapshot)).to.deep.equal([]); // Precondition check.

const storeEvent = new EventsAccumulator<QuerySnapshot>();
onSnapshot(coll, { source: Source.Cache }, storeEvent.storeEvent);
onSnapshot(coll, { source: 'cache' }, storeEvent.storeEvent);
snapshot = await storeEvent.awaitEvent();
expect(snapshot.metadata.fromCache).to.be.true;
expect(toDataArray(snapshot)).to.deep.equal([]);
Expand All @@ -707,7 +706,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const accumulator = new EventsAccumulator<QuerySnapshot>();
const unsubscribe = onSnapshot(
coll,
{ source: Source.Cache },
{ source: 'cache' },
accumulator.storeEvent
);

Expand Down Expand Up @@ -752,7 +751,7 @@ apiDescribe('Snapshot Listener source options ', persistence => {
const storeCacheEvent = new EventsAccumulator<QuerySnapshot>();
const cacheUnlisten = onSnapshot(
testQuery,
{ source: Source.Cache },
{ source: 'cache' },
storeCacheEvent.storeEvent
);
snapshot = await storeCacheEvent.awaitEvent();
Expand Down

0 comments on commit a340dd6

Please sign in to comment.