Skip to content

Commit

Permalink
Fix one README example that were broken by dart-lang/mockito@34b9fdc
Browse files Browse the repository at this point in the history
Also sync the executable version of it with the README.

Fixes dart-lang/mockito#744

PiperOrigin-RevId: 623800048
  • Loading branch information
Ilya Yanok authored and copybara-github committed Apr 11, 2024
1 parent 762ef90 commit 298a6ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pkgs/mockito/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 pkgs/mockito/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 298a6ef

Please sign in to comment.