Skip to content

Commit 8ea3d25

Browse files
author
Andrei Alexandru
committed
modal tests
1 parent 63672f2 commit 8ea3d25

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

views/src/components/Modal.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
3+
import Modal from './Modal';
4+
import store from '../store/index';
5+
6+
test('modal accepts childrens', () => {
7+
const component = mount(<Modal store={store}><div className="childrens">childrens</div></Modal>),
8+
result = component.find('.childrens');
9+
expect(result.text()).toBe('childrens');
10+
});
11+
12+
test('modal click on Close button dispatches MODAL_CLOSE', () => {
13+
const spy = jest.spyOn(store, 'dispatch'),
14+
component = mount(<Modal store={store} modalClose={spy}/>),
15+
close = component.find('CustomButton');
16+
17+
close.simulate('click');
18+
expect(spy).toHaveBeenCalled();
19+
expect(spy.mock.calls[0][0].type).toEqual("MODAL_CLOSE");
20+
});
21+
22+
test('MODAL_OPEN sets status true', () => {
23+
mount(<Modal store={store} />);
24+
25+
store.dispatch({type: "MODAL_OPEN", payload: null});
26+
expect(store.getState().modal.status).toBe(true);
27+
});

0 commit comments

Comments
 (0)