Skip to content

Commit

Permalink
Test that it returns the event object
Browse files Browse the repository at this point in the history
  • Loading branch information
ooade committed May 8, 2020
1 parent 90fe0d2 commit bb29c65
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions __tests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ describe('ClickAway Listener', () => {
expect(fakeHandleClick).toBeCalledTimes(2);
});

it('returns the event object', () => {
const handleClick = (event: MouseEvent | TouchEvent) => {
expect(event.type).toBe('click');
};

const { getByText } = render(
<React.Fragment>
<ClickAwayListener onClickAway={handleClick}>
Hello World
</ClickAwayListener>
<button>A button</button>
</React.Fragment>
);

fireEvent.click(getByText(/A button/i));
});

it('works with different touch events', () => {
const fakeHandleClick = jest.fn();
const { getByText } = render(
Expand Down

0 comments on commit bb29c65

Please sign in to comment.