Skip to content

Commit

Permalink
Merge pull request #60 from jlissner/patch-1
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
timkindberg authored Jan 23, 2021
2 parents b415550 + f5df9a3 commit ea8f335
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ when(fn).calledWith(1).mockReturnValue('yay!')
```

The trained mock function `fn` will now behave as follows -- assumed no other trainings took place:
* return `yay!` if called with `1` _as first parameter_
* return `undefined` if called with _any other first parameter_ than `1`
* return `yay!` if called with `1` _as the only parameter_
* return `undefined` if called with _any parameters other_ than `1`

For extended usage see the examples below.

Expand Down Expand Up @@ -90,14 +90,6 @@ Trainings like `mockReturnValueOnce` are removed after a matching function call

Thanks to [@fkloes](https://github.com/fkloes).

#### Supports multiple args with partial argument matching:
```javascript
when(fn).calledWith(1, true).mockReturnValue('yay!')

expect(fn(1, true)).toEqual('yay!')
expect(fn(1, true, 'foo')).toEqual('yay!')
```

#### Supports training for single calls
```javascript
when(fn).calledWith(1, true, 'foo').mockReturnValueOnce('yay!')
Expand Down

0 comments on commit ea8f335

Please sign in to comment.