Skip to content

Commit

Permalink
Add test for typed providers and named parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
r52 committed Dec 19, 2024
1 parent 6985ddb commit 25416a0
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/riverpod_generator/test/integration/mutation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ class FailingCtor extends _$FailingCtor {
Future<int> increment([int inc = 1]) async => state + inc;
}

@riverpod
class Typed extends _$Typed {
@override
String build() => 'typed';

@mutation
Future<String> mutate(String one,
{required String two, required String three}) async =>
'$one $two $three';
}

// final mut = ref.watch(aProvider(arg).increment);
// mut(2);

Expand Down
155 changes: 155 additions & 0 deletions packages/riverpod_generator/test/integration/mutation.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions packages/riverpod_generator/test/mutation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,19 @@ void main() {
verifyNever(observer.mutationError(any, any, any, any));
});

test('Typed providers and named parameters', () async {
final container = ProviderContainer.test();

final sub = container.listen(typedProvider.mutate, (a, b) {});

await sub.read().call('five', two: 'six', three: 'seven');

expect(
sub.read(),
isMutationBase<String>(state: isSuccessMutationState('five six seven')),
);
});

group('reset', () {
test('Supports calling reset while pending', () async {
final container = ProviderContainer.test();
Expand Down

0 comments on commit 25416a0

Please sign in to comment.