Skip to content

Commit

Permalink
elaborate tests a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
timkindberg committed Nov 1, 2020
1 parent fa68b7f commit 88f5e2b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/when.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,15 @@ describe('When', () => {
const anyString = expect.any(String)

when(fn)
.calledWith(1, 'foo', true, anyString)
.calledWith(1, 'foo', true, anyString, undefined)
.mockReturnValue('x')

expect(fn(1, 'foo', true, 'whatever')).toEqual('x')
expect(fn(1, 'foo', true, 'whatever', undefined)).toEqual('x')
expect(spyEquals).toBeCalledWith(1, 1)
expect(spyEquals).toBeCalledWith('foo', 'foo')
expect(spyEquals).toBeCalledWith(true, true)
expect(spyEquals).toBeCalledWith('whatever', anyString)
expect(spyEquals).toBeCalledWith(undefined, undefined)
})

it('only matches exact sets of args, too little or too many args do not trigger mock return', () => {
Expand All @@ -177,7 +178,10 @@ describe('When', () => {
.calledWith(1, 'foo', true, expect.any(String), undefined)
.mockReturnValue('x')

expect(fn(1, 'foo', true, 'whatever', undefined)).toEqual('x')

expect(fn(1, 'foo', true, 'whatever')).toEqual(undefined)
expect(fn(1, 'foo', true, 'whatever', undefined, undefined)).toEqual(undefined)
expect(fn(1, 'foo', true, 'whatever', undefined, 'oops')).toEqual(undefined)
})

Expand Down

0 comments on commit 88f5e2b

Please sign in to comment.