Adjust unit test after adding conditional render to modals in launch button component

This commit is contained in:
mabashian
2019-09-27 13:47:13 -04:00
parent bb474b0797
commit 518a25430d

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { mountWithContexts, waitForElement } from '@testUtils/enzymeHelpers'; import { mountWithContexts } from '@testUtils/enzymeHelpers';
import { sleep } from '@testUtils/testUtils'; import { sleep } from '@testUtils/testUtils';
import LaunchButton from './LaunchButton'; import LaunchButton from './LaunchButton';
@@ -70,20 +70,15 @@ describe('LaunchButton', () => {
const wrapper = mountWithContexts( const wrapper = mountWithContexts(
<LaunchButton resource={resource}>{children}</LaunchButton> <LaunchButton resource={resource}>{children}</LaunchButton>
); );
const button = wrapper.find('button'); expect(wrapper.find('Modal').length).toBe(0);
button.prop('onClick')(); wrapper.find('button').prop('onClick')();
await waitForElement( await sleep(0);
wrapper, wrapper.update();
'Modal.at-c-alertModal--danger', expect(wrapper.find('Modal').length).toBe(1);
el => el.props().isOpen === true && el.props().title === 'Error!' wrapper.find('ModalBoxCloseButton').simulate('click');
); await sleep(0);
const modalCloseButton = wrapper.find('ModalBoxCloseButton'); wrapper.update();
modalCloseButton.simulate('click'); expect(wrapper.find('Modal').length).toBe(0);
await waitForElement(
wrapper,
'Modal.at-c-alertModal--danger',
el => el.props().isOpen === false
);
done(); done();
}); });
}); });