Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloAny committed Jan 15, 2021
1 parent dd095d0 commit 8f7c630
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,29 @@ describe('dialog', () => {
});
});

it('destroy component when forceRender is true', () => {
const wrapper = mount(
<Dialog destroyOnClose forceRender>
<div>forceRender destroyOnClose</div>
</Dialog>,
);

expect(wrapper.find('.rc-dialog-body > div').text()).toEqual('forceRender destroyOnClose');

// Hide
wrapper.setProps({ visible: true });
jest.runAllTimers();
wrapper.update();

// Show
wrapper.setProps({ visible: false });
jest.runAllTimers();
wrapper.update();

expect(wrapper.find('.rc-dialog-body > div')).toHaveLength(0);
wrapper.unmount();
});

it('esc to close', () => {
const onClose = jest.fn();
const wrapper = mount(<Dialog onClose={onClose} visible />);
Expand Down

0 comments on commit 8f7c630

Please sign in to comment.