Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit b5428b5

Browse files
committed
test(Button): add a test for onClick
1 parent c31ebc9 commit b5428b5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/specs/components/Button/Button-test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,18 @@ describe('Button', () => {
153153

154154
expect(onClick).not.toHaveBeenCalled()
155155
})
156+
157+
test('is called with (e, props) on a click', () => {
158+
const onClick = jest.fn()
159+
const button = mountWithProviderAndGetComponent(Button, <Button onClick={onClick} />)
160+
161+
button.simulate('click')
162+
163+
expect(onClick).toHaveBeenCalledTimes(1)
164+
expect(onClick).toHaveBeenCalledWith(
165+
expect.objectContaining({ type: 'click' }),
166+
expect.objectContaining({ onClick }),
167+
)
168+
})
156169
})
157170
})

0 commit comments

Comments
 (0)