Skip to content

Commit 7eccdce

Browse files
committed
chore: adjust test
1 parent d093098 commit 7eccdce

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

tests/preview.test.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,27 +1054,13 @@ describe('Preview', () => {
10541054
});
10551055

10561056
it('Esc closes preview then modal', () => {
1057-
function NestedTestDemo({ onClose }: { onClose: () => void }) {
1058-
const [visible, setVisible] = useState(false);
1059-
const [open, setOpen] = useState(false);
1060-
return (
1061-
<>
1062-
<button onClick={() => setVisible(true)}>open</button>
1063-
<Dialog visible={visible} onClose={onClose}>
1064-
<Image
1065-
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
1066-
preview={{ open, onOpenChange: setOpen }}
1067-
/>
1068-
</Dialog>
1069-
</>
1070-
);
1071-
}
1072-
10731057
const onClose = jest.fn();
1074-
const { baseElement, getByRole } = render(<NestedTestDemo onClose={onClose} />);
10751058

1076-
fireEvent.click(getByRole('button'));
1077-
expect(getByRole('dialog')).toBeTruthy();
1059+
const { baseElement, getByRole } = render(
1060+
<Dialog visible onClose={onClose}>
1061+
<Image src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" />
1062+
</Dialog>,
1063+
);
10781064

10791065
fireEvent.click(getByRole('img'));
10801066
expect(baseElement.querySelector('.rc-image-preview')).toBeTruthy();

0 commit comments

Comments
 (0)