Skip to content

Commit

Permalink
Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rrousselGit committed Mar 16, 2024
1 parent 0ad6424 commit 510b45b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/riverpod/test/src/core/modifiers/future_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ void main() {
final container = ProviderContainer.test();
final provider = FutureProvider((ref) => 0);

final sub = container.listen(provider.future, (previous, value) {});
final sub = container.listen(
provider.future,
weak: true,
(previous, value) {},
);

expect(container.readProviderElement(provider).hasListeners, true);

Expand Down
15 changes: 15 additions & 0 deletions packages/riverpod/test/src/core/modifiers/select_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,27 @@ void main() {
});

group('handles listen(weak: true)', () {
test(
'supports calling ProviderSubscription.read when no value were emitted yet',
() {
final container = ProviderContainer.test();
final provider = Provider((ref) => 0);

final sub = container.listen(
provider.select((value) => 42),
(previous, value) {},
);

expect(sub.read(), 42);
});

test('closing the subscription updated element.hasListeners', () {
final container = ProviderContainer.test();
final provider = Provider((ref) => 0);

final sub = container.listen(
provider.select((value) => 0),
weak: true,
(previous, value) {},
);

Expand Down
3 changes: 2 additions & 1 deletion packages/riverpod/test/src/core/ref_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,8 @@ void main() {
final container = ProviderContainer.test();
final provider = Provider((ref) => 0);

final sub = container.listen(provider, (previous, value) {});
final sub =
container.listen(provider, weak: true, (previous, value) {});

expect(container.readProviderElement(provider).hasListeners, true);

Expand Down

0 comments on commit 510b45b

Please sign in to comment.