Skip to content

Commit

Permalink
test: Add global click test case
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Nov 30, 2019
1 parent 670432e commit 5986af1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/picker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ describe('Basic', () => {
expect(wrapper.isOpen()).toBeFalsy();
});

it('fixed open need repeat trigger onOpenChange', () => {
const onOpenChange = jest.fn();
mount(<MomentPicker onOpenChange={onOpenChange} open />);

for (let i = 0; i < 10; i += 1) {
const clickEvent = new Event('click');
Object.defineProperty(clickEvent, 'target', {
get: () => document.body,
});
window.dispatchEvent(clickEvent);
expect(onOpenChange).toHaveBeenCalledTimes(i + 1);
}
});

it('disabled should not open', () => {
const wrapper = mount(<MomentPicker open disabled />);
expect(wrapper.isOpen()).toBeFalsy();
Expand Down

1 comment on commit 5986af1

@vercel
Copy link

@vercel vercel bot commented on 5986af1 Nov 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.