Skip to content

Commit

Permalink
test: fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Jan 10, 2025
1 parent b5003e4 commit 7343298
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/portal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Dialog.Portal', () => {
it('event should bubble', () => {
const onClose = jest.fn();

const { container } = render(
render(
<Dialog onClose={onClose} visible>
<Select virtual={false} open>
<Select.Option value="bamboo">Bamboo</Select.Option>
Expand All @@ -30,25 +30,25 @@ describe('Dialog.Portal', () => {

jest.runAllTimers();

fireEvent.mouseDown(container.querySelector('.rc-dialog-section'));
fireEvent.click(container.querySelector('.rc-select-item-option-content'));
fireEvent.mouseUp(container.querySelector('.rc-dialog-section'));
fireEvent.mouseDown(document.querySelector('.rc-dialog-section'));
fireEvent.click(document.querySelector('.rc-select-item-option-content'));
fireEvent.mouseUp(document.querySelector('.rc-dialog-section'));
expect(onClose).not.toHaveBeenCalled();
});

it('dialog dont close when mouseDown in content and mouseUp in wrap', () => {
const onClose = jest.fn();

const { container } = render(
render(
<Dialog onClose={onClose} visible>
content
</Dialog>,
);

jest.runAllTimers();

fireEvent.mouseDown(container.querySelector('.rc-dialog-section'));
fireEvent.mouseUp(container.querySelector('.rc-dialog-wrap'));
fireEvent.mouseDown(document.querySelector('.rc-dialog-section'));
fireEvent.mouseUp(document.querySelector('.rc-dialog-wrap'));
expect(onClose).not.toHaveBeenCalled();
});
});

0 comments on commit 7343298

Please sign in to comment.