Skip to content

Commit

Permalink
Added test for subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoboss committed Feb 20, 2024
1 parent 9e3015b commit 8f159e8
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions test/store/in_memory_backing_store_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,25 @@ void main() {
bStore.set('cModel', cModel);
});

test('returns only changed values', ()
test('subscriptions get notified', ()
{
final store = InMemoryBackingStore()
..set('name', 'Peter')
..set('email', '[email protected]')
..returnOnlyChangedValues = true;

final changedEntries = store.iterate().toList();
expect(changedEntries, hasLength(0));

store.set('name', 'Wendy');
final store = InMemoryBackingStore();

final changedEntries2 = store.iterate().toList();
expect(changedEntries2, hasLength(1));
String? key;
Object? oldValue;
Object? newValue;
final subscriptionId = store.subscribe((k, a, b) {
key = k;
oldValue = a;
newValue = b;
});

store.set('name', 'Peter');

expect(key, 'name');
expect(oldValue, null);
expect(newValue, 'Peter');
expect(subscriptionId, isNotNull);
});
});
}

0 comments on commit 8f159e8

Please sign in to comment.