You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
4 years ago
|
import configureMockStore from 'redux-mock-store';
|
||
|
import { mount } from 'enzyme';
|
||
|
import React from 'react';
|
||
4 years ago
|
import withModalProps from './with-modal-props';
|
||
6 years ago
|
|
||
|
const mockState = {
|
||
|
appState: {
|
||
|
modal: {
|
||
|
modalState: {
|
||
|
props: {
|
||
|
prop1: 'prop1',
|
||
|
prop2: 2,
|
||
|
prop3: true,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
4 years ago
|
describe('withModalProps', () => {
|
||
|
it('should return a component wrapped with modal state props', () => {
|
||
4 years ago
|
const TestComponent = () => <div className="test">Testing</div>;
|
||
|
const WrappedComponent = withModalProps(TestComponent);
|
||
|
const store = configureMockStore()(mockState);
|
||
|
const wrapper = mount(<WrappedComponent store={store} />);
|
||
6 years ago
|
|
||
4 years ago
|
expect(wrapper).toHaveLength(1);
|
||
4 years ago
|
const testComponent = wrapper.find(TestComponent).at(0);
|
||
4 years ago
|
expect(testComponent).toHaveLength(1);
|
||
|
expect(testComponent.find('.test').text()).toStrictEqual('Testing');
|
||
4 years ago
|
const testComponentProps = testComponent.props();
|
||
4 years ago
|
expect(testComponentProps.prop1).toStrictEqual('prop1');
|
||
|
expect(testComponentProps.prop2).toStrictEqual(2);
|
||
|
expect(testComponentProps.prop3).toStrictEqual(true);
|
||
|
expect(typeof testComponentProps.hideModal).toStrictEqual('function');
|
||
4 years ago
|
});
|
||
|
});
|