INNER CODE UNIT · JavaScript
sleep
jacklam718/react-native-modals · __tests__/Dialog.test.js:12
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
it('should render with Default & show/hide Animation correctly', async () => {
const wrapper = mount((
<Modal
modalTitle={<ModalTitle title="Popup Dialog - Default Animation" />}
/>
));
expect(wrapper.instance().state.modalState).toMatchSnapshot();
// show dialog
wrapper.setProps({ visible: true });
expect(wrapper.instance().state.modalState).toMatchSnapshot();
await sleep(DELAY_MS);
expect(wrapper.instance().state.modalState).toMatchSnapshot();
// dismiss dialog
wrapper.setProps({ visible: false });
expect(wrapper.instance().state.modalState).toMatchSnapshot();