@@ -1198,7 +1198,7 @@ apiDescribe('Database', persistence => {
1198
1198
onSnapshot ( docA , ( ) => deferred2 . resolve ( ) ) ;
1199
1199
} ) ;
1200
1200
} ) ;
1201
- return Promise . all ( [ deferred1 . promise , deferred2 . promise ] ) . then ( ( ) => { } ) ;
1201
+ return Promise . all ( [ deferred1 . promise , deferred2 . promise ] ) . then ( ( ) => { } ) ;
1202
1202
} ) ;
1203
1203
} ) ;
1204
1204
@@ -1349,35 +1349,35 @@ apiDescribe('Database', persistence => {
1349
1349
it ( 'QuerySnapshot multiple events for snapshot created by a bundle' , function ( done ) {
1350
1350
this . timeout ( SNAPSHOT_TEST_TIMEOUT ) ;
1351
1351
const testDocs = {
1352
- a : { foo : false } ,
1353
- b : { bar : false }
1352
+ a : { foo : 0 } ,
1354
1353
} ;
1355
1354
void withTestCollection ( persistence , testDocs , async ( coll , db ) => {
1356
1355
const q = query ( coll , orderBy ( documentId ( ) ) ) ;
1357
1356
const querySnap = await getDocs ( q ) ;
1358
1357
const json = querySnap . toJSON ( ) ;
1359
- const updateFound = new Deferred < void > ( ) ;
1358
+ const firstUpdateFound = new Deferred < void > ( ) ;
1359
+ const secondUpdateFound = new Deferred < void > ( ) ;
1360
+ const docRef = querySnap . docs [ 0 ] . ref ;
1360
1361
let count = 0 ;
1361
1362
const unlisten = onSnapshot ( db , json , ( querySnap : QuerySnapshot ) => {
1362
1363
const docs = querySnap . docs ;
1363
1364
expect ( docs ) . to . not . be . null ;
1364
1365
if ( docs ) {
1365
- console . error ( "DEDB count: " , count , " bar: " , docs [ 1 ] . data ( ) )
1366
- if ( count === 0 ) {
1367
- expect ( docs [ 0 ] . data ( ) ) . to . deep . equal ( { foo : true } ) ;
1368
- expect ( docs [ 1 ] . data ( ) ) . to . deep . equal ( { bar : false } ) ;
1369
- } else if ( count === 1 ) {
1370
- expect ( docs [ 0 ] . data ( ) ) . to . deep . equal ( { foo : true } ) ;
1371
- expect ( docs [ 1 ] . data ( ) ) . to . deep . equal ( { bar : true } ) ;
1372
- updateFound . resolve ( ) ;
1373
- }
1366
+ expect ( docs [ 0 ] ) . to . exist ;
1374
1367
count ++ ;
1368
+ if ( docs [ 0 ] !== undefined && count === 1 ) {
1369
+ expect ( docs [ 0 ] . data ( ) ) . to . deep . equal ( { foo : 1 } ) ;
1370
+ firstUpdateFound . resolve ( ) ;
1371
+ } else if ( docs [ 0 ] !== undefined && count === 2 ) {
1372
+ expect ( docs [ 0 ] . data ( ) ) . to . deep . equal ( { foo : 2 } ) ;
1373
+ secondUpdateFound . resolve ( ) ;
1374
+ }
1375
1375
}
1376
1376
} ) ;
1377
- await setDoc ( querySnap . docs [ 0 ] . ref , { foo : true } ) ;
1378
- await waitForPendingWrites ( db ) ;
1379
- await setDoc ( querySnap . docs [ 1 ] . ref , { bar : true } ) ;
1380
- await updateFound . promise ;
1377
+ await setDoc ( docRef , { foo : 1 } ) ;
1378
+ await firstUpdateFound . promise ;
1379
+ await setDoc ( docRef , { foo : 2 } ) ;
1380
+ await secondUpdateFound . promise ;
1381
1381
expect ( count ) . to . equal ( 2 ) ;
1382
1382
unlisten ( ) ;
1383
1383
done ( ) ;
@@ -1421,7 +1421,7 @@ apiDescribe('Database', persistence => {
1421
1421
const queryForRejection = collection ( db , 'a/__badpath__/b' ) ;
1422
1422
onSnapshot (
1423
1423
queryForRejection ,
1424
- ( ) => { } ,
1424
+ ( ) => { } ,
1425
1425
( err : Error ) => {
1426
1426
expect ( err . name ) . to . exist ;
1427
1427
expect ( err . message ) . to . exist ;
@@ -1438,13 +1438,13 @@ apiDescribe('Database', persistence => {
1438
1438
const queryForRejection = collection ( db , 'a/__badpath__/b' ) ;
1439
1439
onSnapshot (
1440
1440
queryForRejection ,
1441
- ( ) => { } ,
1441
+ ( ) => { } ,
1442
1442
( err : Error ) => {
1443
1443
expect ( err . name ) . to . exist ;
1444
1444
expect ( err . message ) . to . exist ;
1445
1445
onSnapshot (
1446
1446
queryForRejection ,
1447
- ( ) => { } ,
1447
+ ( ) => { } ,
1448
1448
( err2 : Error ) => {
1449
1449
expect ( err2 . name ) . to . exist ;
1450
1450
expect ( err2 . message ) . to . exist ;
@@ -1859,7 +1859,7 @@ apiDescribe('Database', persistence => {
1859
1859
it ( 'can query after firestore restart' , async ( ) => {
1860
1860
return withTestDoc ( persistence , async ( docRef , firestore ) => {
1861
1861
const deferred : Deferred < FirestoreError > = new Deferred ( ) ;
1862
- const unsubscribe = onSnapshot ( docRef , snapshot => { } , deferred . resolve ) ;
1862
+ const unsubscribe = onSnapshot ( docRef , snapshot => { } , deferred . resolve ) ;
1863
1863
1864
1864
await firestore . _restart ( ) ;
1865
1865
@@ -1879,7 +1879,7 @@ apiDescribe('Database', persistence => {
1879
1879
it ( 'query listener throws error on termination' , async ( ) => {
1880
1880
return withTestDoc ( persistence , async ( docRef , firestore ) => {
1881
1881
const deferred : Deferred < FirestoreError > = new Deferred ( ) ;
1882
- const unsubscribe = onSnapshot ( docRef , snapshot => { } , deferred . resolve ) ;
1882
+ const unsubscribe = onSnapshot ( docRef , snapshot => { } , deferred . resolve ) ;
1883
1883
1884
1884
await terminate ( firestore ) ;
1885
1885
@@ -1926,7 +1926,7 @@ apiDescribe('Database', persistence => {
1926
1926
readonly title : string ,
1927
1927
readonly author : string ,
1928
1928
readonly ref : DocumentReference | null = null
1929
- ) { }
1929
+ ) { }
1930
1930
byline ( ) : string {
1931
1931
return this . title + ', by ' + this . author ;
1932
1932
}
@@ -2056,8 +2056,8 @@ apiDescribe('Database', persistence => {
2056
2056
batch . set ( ref , { title : 'olive' } , { merge : true } )
2057
2057
) . to . throw (
2058
2058
'Function WriteBatch.set() called with invalid ' +
2059
- 'data (via `toFirestore()`). Unsupported field value: undefined ' +
2060
- '(found in field author in document posts/some-post)'
2059
+ 'data (via `toFirestore()`). Unsupported field value: undefined ' +
2060
+ '(found in field author in document posts/some-post)'
2061
2061
) ;
2062
2062
} ) ;
2063
2063
} ) ;
0 commit comments