You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following test fails and shows other incorrect behavior: docChanges is not reporting changes but the new contents of the collection. Nothing is ever deleted, and elements are added multiple times.
The correct sequence of events is "add 1" "add 2" "delete 2", but what is seen is "add 1" "add 1" "add 2" "add 1".
This behavior makes applications that use docChanges not testable with the fake.
import'package:cloud_firestore/cloud_firestore.dart';
import'package:fake_cloud_firestore/fake_cloud_firestore.dart';
import'package:flutter/foundation.dart';
import'package:flutter_test/flutter_test.dart';
voidmain() {
test('Deleting should trigger a delete doc change', () async {
finalSet<String> ids = {};
final db =FakeFirebaseFirestore();
final sub = db.collection('docs').snapshots().listen((querySnapshot) {
for (final change in querySnapshot.docChanges) {
debugPrint('${change.type}${change.doc.id}');
switch (change.type) {
caseDocumentChangeType.removed:
ids.remove(change.doc.id);
break;
default:
ids.add(change.doc.id);
break;
}
}
});
addTearDown(sub.cancel);
await db.collection('docs').doc('1').set(<String, dynamic>{});
awaitpumpEventQueue();
expect(ids, {'1'});
await db.collection('docs').doc('2').set(<String, dynamic>{});
awaitpumpEventQueue();
expect(ids, {'1', '2'});
await db.collection('docs').doc('2').delete();
awaitpumpEventQueue();
expect(ids, {'1'});
});
}
The text was updated successfully, but these errors were encountered:
The following test fails and shows other incorrect behavior:
docChanges
is not reporting changes but the new contents of the collection. Nothing is ever deleted, and elements are added multiple times.The correct sequence of events is "add 1" "add 2" "delete 2", but what is seen is "add 1" "add 1" "add 2" "add 1".
This behavior makes applications that use
docChanges
not testable with the fake.The text was updated successfully, but these errors were encountered: