Created
December 5, 2019 12:27
-
-
Save sharvit/b7d193c033d9c5fe6371eb4efb27a467 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ForemanModal, { reducers } from './index'; | |
import { setModalOpen, setModalClosed } from './ForemanModalActions'; | |
import IntegrationTestHelper from '../../common/IntegrationTestHelper'; | |
describe('ForemanModal - integration test', () => { | |
it('should flow', () => { | |
const integrationTestHelper = new IntegrationTestHelper(reducers); | |
integrationTestHelper.takeStoreSnapshot('initial state'); | |
const modal1 = integrationTestHelper.mount( | |
<ForemanModal id="modal1" title="modal1 title" /> | |
); | |
const modal2 = integrationTestHelper.mount( | |
<ForemanModal id="modal2" title="modal1 title" /> | |
); | |
const modal3 = integrationTestHelper.mount( | |
<ForemanModal id="modal3" title="modal1 title" /> | |
); | |
integrationTestHelper.takeStoreSnapshot('state after adding 3 modals'); | |
const isModalShown = modal => | |
modal | |
.find('Modal') | |
.first() | |
.props().show; | |
// modal1 should not be shown | |
expect(isModalShown(modal1)).toEqual(false); | |
expect(isModalShown(modal2)).toEqual(false); | |
expect(isModalShown(modal3)).toEqual(false); | |
// open modal1 | |
integrationTestHelper.store.dispatch(setModalOpen('modal1')); | |
// verify state after open modal1 | |
integrationTestHelper.takeStoreAndLastActionSnapshot( | |
'after opening modal1' | |
); | |
expect(isModalShown(modal1)).toEqual(true); | |
expect(isModalShown(modal2)).toEqual(false); | |
expect(isModalShown(modal3)).toEqual(false); | |
// open modal2 | |
integrationTestHelper.store.dispatch(setModalOpen('modal2')); | |
// verify state after open modal1 | |
integrationTestHelper.takeStoreAndLastActionSnapshot( | |
'after opening modal2' | |
); | |
expect(isModalShown(modal1)).toEqual(true); | |
expect(isModalShown(modal2)).toEqual(true); | |
expect(isModalShown(modal3)).toEqual(false); | |
// close modal1 | |
integrationTestHelper.store.dispatch(setModalClosed('modal1')); | |
// verify state after open modal1 | |
integrationTestHelper.takeStoreAndLastActionSnapshot( | |
'after closing modal1' | |
); | |
expect(isModalShown(modal1)).toEqual(false); | |
expect(isModalShown(modal2)).toEqual(true); | |
expect(isModalShown(modal3)).toEqual(false); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment