-
Notifications
You must be signed in to change notification settings - Fork 7
/
ProductProperties.spec.jsx
43 lines (35 loc) · 1.27 KB
/
ProductProperties.spec.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import { mount } from 'enzyme';
import configureStore from 'redux-mock-store';
import mockConsole from 'jest-mock-console';
import ProductProperties from '../ProductProperties';
import { makeGetProductProperties } from '../../../selectors/product';
const mockStore = configureStore();
const store = mockStore({});
jest.mock('../../../selectors/product', () => ({
makeGetProductProperties: jest.fn(() => jest.fn()),
}));
const properties = [
{ displayGroup: 'test' },
];
describe('<ProductProperties />', () => {
let restoreConsole;
beforeEach(() => {
restoreConsole = mockConsole();
});
afterEach(() => {
restoreConsole();
});
it('should not render if no properties where passed', () => {
makeGetProductProperties.mockReturnValueOnce(() => null);
const wrapper = mount(<ProductProperties key="1" store={store} />);
expect(wrapper.find('ProductProperties').instance()).toEqual(null);
expect(wrapper).toMatchSnapshot();
});
it('should render if properties are passed', () => {
makeGetProductProperties.mockReturnValueOnce(() => properties);
const wrapper = mount(<ProductProperties key="2" store={store} />);
expect(wrapper.find('Content').length).toEqual(1);
expect(wrapper).toMatchSnapshot();
});
});