Skip to content

Commit

Permalink
Fix one README example that were broken by 1dcd822
Browse files Browse the repository at this point in the history
Also sync the executable version of it with the README.

Fixes #744

PiperOrigin-RevId: 623800048
  • Loading branch information
Ilya Yanok authored and copybara-github committed Apr 11, 2024
1 parent 3ef744f commit 81ecb88
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,17 @@ In most cases, both plain arguments and argument matchers can be passed into
mock methods:

```dart
// You can use plain arguments themselves
// You can use `any`
when(cat.eatFood(any)).thenReturn(false);
// ... or plain arguments themselves
when(cat.eatFood("fish")).thenReturn(true);
// ... including collections
when(cat.walk(["roof","tree"])).thenReturn(2);
// ... or matchers
when(cat.eatFood(argThat(startsWith("dry")))).thenReturn(false);
when(cat.eatFood(any)).thenReturn(false);
// ... or mix arguments with matchers
when(cat.eatFood(argThat(startsWith("dry")), hungry: true)).thenReturn(true);
Expand Down
7 changes: 5 additions & 2 deletions example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ void main() {
});

test('Argument matchers', () {
// You can use plain arguments themselves
when(cat.eatFood('fish')).thenReturn(true);
// You can use `any`
when(cat.eatFood(any)).thenReturn(false);

// ... or plain arguments themselves
when(cat.eatFood("fish")).thenReturn(true);

// ... including collections
when(cat.walk(['roof', 'tree'])).thenReturn(2);
Expand Down

0 comments on commit 81ecb88

Please sign in to comment.