@shopgate/engage 7.31.5 → 7.31.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/mocks/date.js +31 -0
  2. package/mocks/index.js +3 -0
  3. package/mocks/pipelineRequest.js +1 -0
  4. package/mocks/subscriptions.js +1 -0
  5. package/package.json +7 -7
  6. package/product/selectors/mocks/productProperties.mock.js +49 -0
  7. package/components/ChipLayout/spec.js +0 -41
  8. package/components/Logo/spec.js +0 -12
  9. package/components/NavigationHandler/spec.js +0 -84
  10. package/components/Picker/spec.js +0 -87
  11. package/components/PickerUtilize/spec.js +0 -32
  12. package/components/RangeSlider/spec.js +0 -190
  13. package/components/SheetList/components/Item/spec.js +0 -101
  14. package/components/SheetList/spec.js +0 -43
  15. package/components/TimeBoundary/spec.js +0 -83
  16. package/filter/components/FilterItem/spec.js +0 -14
  17. package/filter/components/FilterPageContent/components/ApplyButton/spec.js +0 -46
  18. package/filter/components/FilterPageContent/components/ResetButton/spec.js +0 -29
  19. package/filter/components/FilterPageContent/components/Selector/components/Selected/spec.js +0 -26
  20. package/filter/components/FilterPageContent/components/Selector/components/Toggle/spec.js +0 -34
  21. package/filter/components/FilterPageContent/components/Selector/components/ValueButton/spec.js +0 -32
  22. package/filter/components/FilterPageContent/components/Selector/spec.js +0 -33
  23. package/filter/components/PriceSlider/components/Label/spec.js +0 -17
  24. package/filter/components/PriceSlider/spec.js +0 -25
  25. package/product/components/FilterBar/components/Content/spec.js +0 -136
  26. package/product/components/Header/Shipping/spec.js +0 -37
  27. package/product/components/Header/Tiers/components/Tier/spec.js +0 -48
  28. package/product/components/Header/Tiers/spec.js +0 -64
  29. package/product/components/Options/components/Content/spec.js +0 -73
  30. package/product/components/Options/components/TextOption/components/OptionInfo/spec.js +0 -63
  31. package/product/components/ProductDiscountBadge/spec.js +0 -58
  32. package/product/components/ProductGrid/components/Item/components/ItemDetails/spec.js +0 -73
  33. package/product/components/ProductGrid/components/Item/components/ItemFavoritesButton/spec.js +0 -33
  34. package/product/components/ProductGrid/components/Item/components/ItemImage/spec.js +0 -16
  35. package/product/components/ProductGrid/components/Item/components/ItemName/spec.js +0 -21
  36. package/product/components/ProductGrid/components/Item/components/ItemPrice/spec.js +0 -37
  37. package/product/components/ProductGrid/spec.js +0 -52
  38. package/product/components/ProductImage/spec.js +0 -87
  39. package/product/components/ProductSlider/spec.js +0 -37
  40. package/product/components/Rating/spec.js +0 -57
  41. package/reviews/components/Reviews/components/Header/components/WriteReviewLink/spec.js +0 -35
  42. package/reviews/components/Reviews/components/Header/spec.js +0 -60
  43. package/reviews/components/Reviews/components/List/spec.js +0 -69
  44. package/reviews/components/Reviews/components/RatingCount/spec.js +0 -18
  45. package/reviews/components/Reviews/spec.js +0 -73
  46. package/tsconfig.build.json +0 -26
  47. package/tsconfig.json +0 -18
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import { mount } from 'enzyme';
3
- import BaseListItem from '@shopgate/pwa-common/components/List/components/Item';
4
- import SheetList from "./index";
5
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
- describe('<SheetList />', () => {
7
- it('should render with two children', () => {
8
- const wrapper = mount(/*#__PURE__*/_jsxs(SheetList, {
9
- children: [/*#__PURE__*/_jsx(SheetList.Item, {
10
- title: "List Item"
11
- }), /*#__PURE__*/_jsx(SheetList.Item, {
12
- title: "List Item"
13
- })]
14
- }));
15
- expect(wrapper).toMatchSnapshot();
16
- expect(wrapper.find(SheetList.Item).length).toEqual(2);
17
- });
18
- it('should render a child and add styles for list items with images', () => {
19
- const wrapper = mount(/*#__PURE__*/_jsx(SheetList, {
20
- hasImages: true,
21
- children: /*#__PURE__*/_jsx(SheetList.Item, {
22
- title: "List Item"
23
- })
24
- }));
25
- expect(wrapper).toMatchSnapshot();
26
- expect(wrapper.find(SheetList.Item).length).toEqual(1);
27
- expect(wrapper.find(BaseListItem).first().hasClass('engage__sheet-list__item')).toBeTruthy();
28
- });
29
- it('should not render without children', () => {
30
- const wrapper = mount(/*#__PURE__*/_jsx(SheetList, {}));
31
- expect(wrapper).toMatchSnapshot();
32
- expect(wrapper.find(SheetList).html()).toBe(null);
33
- });
34
- it('should not render invalid children', () => {
35
- const wrapper = mount(/*#__PURE__*/_jsxs(SheetList, {
36
- children: [/*#__PURE__*/_jsx(SheetList.Item, {
37
- title: "List Item"
38
- }), "xxx"]
39
- }));
40
- expect(wrapper).toMatchSnapshot();
41
- expect(wrapper.find(SheetList.Item).length).toEqual(1);
42
- });
43
- });
@@ -1,83 +0,0 @@
1
- /* eslint-disable extra-rules/no-single-line-objects */
2
- import React from 'react';
3
- import { mount } from 'enzyme';
4
- import { second$ } from '@shopgate/pwa-common/streams/interval';
5
- import TimeBoundary from "./index";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- describe('<TimeBoundary>', () => {
8
- const nowMs = new Date().getTime();
9
- let subscription;
10
- let subscribeSpy;
11
- let children;
12
- beforeEach(() => {
13
- subscription = {
14
- unsubscribe: jest.fn()
15
- };
16
- subscribeSpy = jest.spyOn(second$, 'subscribe').mockReturnValue(subscription);
17
- children = jest.fn();
18
- });
19
- afterEach(() => {
20
- jest.clearAllMocks();
21
- });
22
- it('should render valid time span', () => {
23
- expect.assertions(1);
24
- // -30sec < wrapper < +30sec
25
- mount(/*#__PURE__*/_jsx(TimeBoundary, {
26
- start: new Date(nowMs - 30000),
27
- end: new Date(nowMs + 30000),
28
- children: children
29
- }));
30
- expect(children).toHaveBeenCalledWith({
31
- before: false,
32
- between: true,
33
- after: false
34
- });
35
- });
36
- it('should not render expired time span', () => {
37
- expect.assertions(1);
38
- // -60sec < wrapper < -30sec
39
- mount(/*#__PURE__*/_jsx(TimeBoundary, {
40
- start: new Date(nowMs - 60000),
41
- end: new Date(nowMs - 30000),
42
- children: children
43
- }));
44
- expect(children).toHaveBeenCalledWith({
45
- before: false,
46
- between: false,
47
- after: true
48
- });
49
- });
50
- it('should hide after time span expired', () => {
51
- expect.assertions(4);
52
- // -30sec < wrapper < +2sec
53
- const wrapper = mount(/*#__PURE__*/_jsx(TimeBoundary, {
54
- start: new Date(nowMs - 30000),
55
- end: new Date(nowMs + 2000),
56
- children: children
57
- }));
58
- const checkBoundaryMethod = wrapper.instance().checkBoundary;
59
- expect(subscribeSpy).toHaveBeenCalledTimes(1);
60
- expect(subscribeSpy).toHaveBeenCalledWith(checkBoundaryMethod);
61
-
62
- // Simulate time is over
63
- jest.spyOn(Date, 'now').mockReturnValue(new Date(nowMs + 3000));
64
- // simulate rxjs emitting
65
- checkBoundaryMethod();
66
- wrapper.update();
67
- expect(subscription.unsubscribe).toHaveBeenCalledTimes(1);
68
- expect(children.mock.calls).toEqual([[{
69
- after: false,
70
- before: false,
71
- between: false
72
- }], [{
73
- after: false,
74
- before: false,
75
- between: true
76
- }], [{
77
- after: true,
78
- before: false,
79
- between: false
80
- }]]);
81
- });
82
- });
83
- /* eslint-enable extra-rules/no-single-line-objects */
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import Item from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- describe('Filter: <Item />', () => {
6
- it('should render', () => {
7
- const wrapper = shallow(/*#__PURE__*/_jsx(Item, {
8
- children: /*#__PURE__*/_jsx("div", {
9
- children: "Some"
10
- })
11
- }));
12
- expect(wrapper).toMatchSnapshot();
13
- });
14
- });
@@ -1,46 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import ApplyButton from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const clickMock = jest.fn();
6
- jest.mock('@shopgate/engage/components');
7
- jest.mock('@shopgate/engage/core', () => ({
8
- withWidgetSettings: function withWidgetSettings(Comp) {
9
- return props => /*#__PURE__*/_jsx(Comp, {
10
- widgetSettings: {},
11
- ...props
12
- });
13
- }
14
- }));
15
- jest.mock('@shopgate/engage/components', () => ({
16
- SurroundPortals: ({
17
- children
18
- }) => children,
19
- I18n: {
20
- Text: () => 'I18n.Text'
21
- },
22
- Button: () => 'Button'
23
- }));
24
- describe('Filter: <ApplyButton />', () => {
25
- it('should render as activated', () => {
26
- const wrapper = shallow(/*#__PURE__*/_jsx(ApplyButton, {
27
- onClick: () => {}
28
- })).dive();
29
- expect(wrapper).toMatchSnapshot();
30
- });
31
- it('should render as deactivated', () => {
32
- const wrapper = shallow(/*#__PURE__*/_jsx(ApplyButton, {
33
- disabled: true,
34
- onClick: () => {}
35
- })).dive();
36
- expect(wrapper).toMatchSnapshot();
37
- });
38
- it('should handle clicks', () => {
39
- const wrapper = shallow(/*#__PURE__*/_jsx(ApplyButton, {
40
- onClick: clickMock
41
- })).dive();
42
- expect(wrapper).toMatchSnapshot();
43
- wrapper.find('Button').simulate('click');
44
- expect(clickMock).toHaveBeenCalled();
45
- });
46
- });
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import ResetButton from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const clickMock = jest.fn();
6
- jest.mock('@shopgate/engage/components');
7
- describe('Filter: <ResetButton />', () => {
8
- it('should render as activated', () => {
9
- const wrapper = shallow(/*#__PURE__*/_jsx(ResetButton, {
10
- onClick: () => {}
11
- }));
12
- expect(wrapper).toMatchSnapshot();
13
- });
14
- it('should render as deactivated', () => {
15
- const wrapper = shallow(/*#__PURE__*/_jsx(ResetButton, {
16
- disabled: true,
17
- onClick: () => {}
18
- }));
19
- expect(wrapper).toMatchSnapshot();
20
- });
21
- it('should handle clicks', () => {
22
- const wrapper = shallow(/*#__PURE__*/_jsx(ResetButton, {
23
- onClick: clickMock
24
- }));
25
- expect(wrapper).toMatchSnapshot();
26
- wrapper.find('Button').simulate('click');
27
- expect(clickMock).toHaveBeenCalled();
28
- });
29
- });
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import Selected from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const values = [{
6
- id: 'foo',
7
- label: 'fooLabel'
8
- }, {
9
- id: 'bar',
10
- label: 'barLabel'
11
- }];
12
- describe('Filter: <Selected />', () => {
13
- it('should not render without selected', () => {
14
- const wrapper = shallow(/*#__PURE__*/_jsx(Selected, {
15
- values: values
16
- }));
17
- expect(wrapper).toMatchSnapshot();
18
- });
19
- it('should render with selected', () => {
20
- const wrapper = shallow(/*#__PURE__*/_jsx(Selected, {
21
- values: values,
22
- selected: ['foo']
23
- }));
24
- expect(wrapper).toMatchSnapshot();
25
- });
26
- });
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- import { render } from 'enzyme';
3
- import Toggle from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- describe('<Toggle />', () => {
6
- it('should render without selected', () => {
7
- const wrapper = render(/*#__PURE__*/_jsx(Toggle, {
8
- label: "somelabel"
9
- }));
10
- expect(wrapper).toMatchSnapshot();
11
- });
12
- it('should render without selected as open', () => {
13
- const wrapper = render(/*#__PURE__*/_jsx(Toggle, {
14
- label: "somelabel",
15
- open: true
16
- }));
17
- expect(wrapper).toMatchSnapshot();
18
- });
19
- it('should render with selected', () => {
20
- const wrapper = render(/*#__PURE__*/_jsx(Toggle, {
21
- label: "somelabel",
22
- selected: "Some, Thing, Selected"
23
- }));
24
- expect(wrapper).toMatchSnapshot();
25
- });
26
- it('should render with selected as open', () => {
27
- const wrapper = render(/*#__PURE__*/_jsx(Toggle, {
28
- label: "somelabel",
29
- selected: "Some, Thing, Selected",
30
- open: true
31
- }));
32
- expect(wrapper).toMatchSnapshot();
33
- });
34
- });
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import ValueButton from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const onClick = jest.fn();
6
- describe('<ValueButton />', () => {
7
- it('should render as inactive', () => {
8
- const wrapper = shallow(/*#__PURE__*/_jsx(ValueButton, {
9
- id: "someid",
10
- label: "somelabel"
11
- }));
12
- expect(wrapper).toMatchSnapshot();
13
- });
14
- it('should render as active', () => {
15
- const wrapper = shallow(/*#__PURE__*/_jsx(ValueButton, {
16
- id: "someid",
17
- label: "somelabel",
18
- isActive: true
19
- }));
20
- expect(wrapper).toMatchSnapshot();
21
- });
22
- it('should handle click event', () => {
23
- const wrapper = shallow(/*#__PURE__*/_jsx(ValueButton, {
24
- id: "someid",
25
- label: "somelabel",
26
- onClick: onClick
27
- }));
28
- wrapper.simulate('click');
29
- expect(wrapper).toMatchSnapshot();
30
- expect(onClick).toHaveBeenCalledTimes(1);
31
- });
32
- });
@@ -1,33 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import Selector from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- jest.mock('@shopgate/engage/core', () => ({
6
- hasWebBridge: () => false,
7
- i18n: {
8
- text: string => string
9
- }
10
- }));
11
- jest.mock('@shopgate/engage/components');
12
- jest.mock('@shopgate/engage/filter', () => ({
13
- FilterItem: ({
14
- children
15
- }) => children
16
- }));
17
- const values = [{
18
- id: 'foo',
19
- label: 'fooLabel'
20
- }, {
21
- id: 'bar',
22
- label: 'barLabel'
23
- }];
24
- describe('Filter: <Selector />', () => {
25
- it('should render with minimum props', () => {
26
- const wrapper = shallow(/*#__PURE__*/_jsx(Selector, {
27
- id: "foo",
28
- label: "bar",
29
- values: values
30
- }));
31
- expect(wrapper).toMatchSnapshot();
32
- });
33
- });
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import Label from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- jest.mock('@shopgate/engage/components');
6
- jest.mock('@shopgate/engage/core');
7
- describe('PriceSlider: <Label />', () => {
8
- it('should render', () => {
9
- const wrapper = shallow(/*#__PURE__*/_jsx(Label, {
10
- onChange: () => {},
11
- priceLength: "5",
12
- priceMax: 999,
13
- priceMin: 25
14
- }));
15
- expect(wrapper).toMatchSnapshot();
16
- });
17
- });
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import PriceSlider from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- jest.mock('@shopgate/engage/components');
6
- jest.mock('@shopgate/engage/filter', () => ({
7
- FilterItem: ({
8
- children
9
- }) => children
10
- }));
11
- describe('Filter: <PriceSlider />', () => {
12
- it('should render with default props', () => {
13
- const wrapper = shallow(/*#__PURE__*/_jsx(PriceSlider, {
14
- id: "foo"
15
- }));
16
- expect(wrapper).toMatchSnapshot();
17
- });
18
- it('should render with custom props', () => {
19
- const wrapper = shallow(/*#__PURE__*/_jsx(PriceSlider, {
20
- id: "foo",
21
- values: [5, 50]
22
- }));
23
- expect(wrapper).toMatchSnapshot();
24
- });
25
- });
@@ -1,136 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
- import TestUtils from 'react-dom/test-utils';
4
- import { mount, shallow } from 'enzyme';
5
- import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
6
- import { FILTER_TYPE_MULTISELECT } from '@shopgate/pwa-common-commerce/filter/constants';
7
- import GridIcon from '@shopgate/pwa-ui-shared/icons/GridIcon';
8
- import ListIcon from '@shopgate/pwa-ui-shared/icons/ListIcon';
9
- // eslint-disable-next-line import/named
10
- import { UnwrappedContent as FilterBarContent } from "./index";
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- const activeFilters = {
13
- Size: {
14
- label: 'Size',
15
- source: 'attributes',
16
- type: FILTER_TYPE_MULTISELECT,
17
- values: ['31']
18
- }
19
- };
20
- describe.skip('<FilterBarContent />', () => {
21
- it('should execute handleToggleViewMode callback when left button is clicked', () => {
22
- const spy = jest.fn();
23
- const wrapper = mount(/*#__PURE__*/_jsx(FilterBarContent, {
24
- handleToggleViewMode: spy,
25
- handleSortChange: () => {},
26
- handleOpenFiltersView: () => {},
27
- getFilters: () => {},
28
- componentUpdated: () => {}
29
- }), mockRenderOptions);
30
- const button = wrapper.find('button').first();
31
- const node = ReactDOM.findDOMNode(button.node); // eslint-disable-line react/no-find-dom-node
32
- TestUtils.Simulate.click(node);
33
- expect(spy).toHaveBeenCalledTimes(1);
34
- });
35
- it('should execute handleOpenFiltersView callback when right button is clicked', () => {
36
- const spy = jest.fn();
37
- const wrapper = mount(/*#__PURE__*/_jsx(FilterBarContent, {
38
- handleToggleViewMode: () => {},
39
- handleSortChange: () => {},
40
- handleOpenFiltersView: spy,
41
- getFilters: () => {},
42
- componentUpdated: () => {}
43
- }), mockRenderOptions);
44
- const button = wrapper.find('button').last();
45
- const node = ReactDOM.findDOMNode(button.node); // eslint-disable-line react/no-find-dom-node
46
- TestUtils.Simulate.click(node);
47
- expect(spy).toHaveBeenCalledTimes(1);
48
- });
49
- it('should render in grid view mode', () => {
50
- const wrapper = mount(/*#__PURE__*/_jsx(FilterBarContent, {
51
- handleToggleViewMode: () => {},
52
- handleSortChange: () => {},
53
- handleOpenFiltersView: () => {},
54
- getFilters: () => {},
55
- componentUpdated: () => {}
56
- }), mockRenderOptions);
57
- expect(wrapper).toMatchSnapshot();
58
- expect(wrapper.find(GridIcon).length).toEqual(0);
59
- expect(wrapper.find(ListIcon).length).toEqual(1);
60
- });
61
- it('should render in list view mode', () => {
62
- const wrapper = mount(/*#__PURE__*/_jsx(FilterBarContent, {
63
- handleToggleViewMode: () => {},
64
- handleSortChange: () => {},
65
- handleOpenFiltersView: () => {},
66
- getFilters: () => {},
67
- componentUpdated: () => {}
68
- }), mockRenderOptions);
69
- expect(wrapper).toMatchSnapshot();
70
- expect(wrapper.find(GridIcon).length).toEqual(1);
71
- expect(wrapper.find(ListIcon).length).toEqual(0);
72
- });
73
- describe('should call getFilters', () => {
74
- let getFiltersSpy = null;
75
- let filterBarWrapper = null;
76
- let filterBarInstance = null;
77
- beforeEach(() => {
78
- getFiltersSpy = jest.fn();
79
- filterBarWrapper = shallow(/*#__PURE__*/_jsx(FilterBarContent, {
80
- handleToggleViewMode: () => {},
81
- handleSortChange: () => {},
82
- getFilters: getFiltersSpy,
83
- componentUpdated: () => {}
84
- }), mockRenderOptions);
85
- filterBarInstance = filterBarWrapper.instance();
86
- });
87
- it('should call getFilters at componentDidMount', () => {
88
- filterBarInstance.componentDidMount();
89
- expect(getFiltersSpy).toHaveBeenCalledTimes(1);
90
- });
91
- it('should call getFilters at props.activeFilter changes', () => {
92
- filterBarWrapper.setProps({
93
- activeFilters
94
- });
95
- expect(getFiltersSpy).toHaveBeenCalledTimes(1);
96
- });
97
- });
98
- describe('Given activeFilters are handled correctly', () => {
99
- let filterBarWrapper = null;
100
- beforeEach(() => {
101
- filterBarWrapper = mount(/*#__PURE__*/_jsx(FilterBarContent, {
102
- handleToggleViewMode: () => {},
103
- handleSortChange: () => {},
104
- getFilters: () => {},
105
- activeFilters: activeFilters,
106
- componentUpdated: () => {}
107
- }), mockRenderOptions);
108
- });
109
- it('should render active filters', () => {
110
- expect(filterBarWrapper).toMatchSnapshot();
111
- });
112
- it('should open active filters', () => {
113
- const spy = jest.fn();
114
- filterBarWrapper.setProps({
115
- handleOpenFiltersView: spy
116
- });
117
-
118
- // Trigger a click on a active filter
119
- filterBarWrapper.find('Chip').at(0).find('button').at(1).simulate('click');
120
- expect(spy).toHaveBeenCalledTimes(1);
121
- });
122
- it('should remove active filter', () => {
123
- const removeFilterSpy = jest.fn();
124
- const commmitFilterSpy = jest.fn();
125
- filterBarWrapper.setProps({
126
- removeTemporaryFilter: removeFilterSpy,
127
- commitTemporaryFilters: commmitFilterSpy
128
- });
129
-
130
- // Trigger a click on the "X"
131
- filterBarWrapper.find('Chip').at(0).find('button').at(0).simulate('click');
132
- expect(removeFilterSpy).toHaveBeenCalledWith(Object.keys(activeFilters)[0], 0);
133
- expect(commmitFilterSpy).toHaveBeenCalledTimes(1);
134
- });
135
- });
136
- });
@@ -1,37 +0,0 @@
1
- import "core-js/modules/es.array.includes.js";
2
- import React from 'react';
3
- import { Provider } from 'react-redux';
4
- import configureStore from 'redux-mock-store';
5
- import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
6
- import { mount } from 'enzyme';
7
- import Shipping from "./index";
8
- import { mockedStoreWithShippingPrice, mockedStoreWithFreeShipping, mockedStoreWithUnknownShipping } from "./mock";
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- const mockedStore = configureStore();
11
- describe('Shipping label', () => {
12
- /**
13
- * Creates connected the component
14
- * @param {Object} state The mocked redux state
15
- * @return {ReactWrapper}
16
- */
17
- const createComponent = state => mount(/*#__PURE__*/_jsx(Provider, {
18
- store: mockedStore(state),
19
- children: /*#__PURE__*/_jsx(Shipping, {
20
- productId: "fakeId"
21
- })
22
- }), mockRenderOptions);
23
- it('should render shipping price', () => {
24
- const component = createComponent(mockedStoreWithShippingPrice);
25
- expect(component).toMatchSnapshot();
26
- expect(component.html().includes('shipping.cost')).toBe(true);
27
- });
28
- it('should render free shipping', () => {
29
- const component = createComponent(mockedStoreWithFreeShipping);
30
- expect(component).toMatchSnapshot();
31
- expect(component.html().includes('shipping.free')).toBe(true);
32
- });
33
- it('should not render when shipping is unknown', () => {
34
- const component = createComponent(mockedStoreWithUnknownShipping);
35
- expect(component.isEmptyRender()).toBe(true);
36
- });
37
- });
@@ -1,48 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import Tier from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- describe('<Tier />', () => {
6
- describe('Rendering with data', () => {
7
- it('should render tier prices when tier prices are available', () => {
8
- const price = {
9
- tiers: [{
10
- from: 1,
11
- to: 2,
12
- unitPrice: 92.5
13
- }, {
14
- from: 3,
15
- to: 5,
16
- unitPrice: 77.5
17
- }, {
18
- from: 6,
19
- to: null,
20
- unitPrice: 68.5
21
- }],
22
- currency: 'USD'
23
- };
24
- const tier = {
25
- from: 3,
26
- to: 5,
27
- unitPrice: 77.5
28
- };
29
- const wrapper = shallow(/*#__PURE__*/_jsx(Tier, {
30
- price: price,
31
- tier: tier
32
- }));
33
- expect(wrapper).toMatchSnapshot();
34
- });
35
- });
36
- describe('Rendering without data', () => {
37
- it('should render nothing when tier from is less then 1', () => {
38
- const tier = {
39
- from: 1
40
- };
41
- const wrapper = shallow(/*#__PURE__*/_jsx(Tier, {
42
- tier: tier,
43
- price: {}
44
- }));
45
- expect(wrapper).toBeEmptyRender();
46
- });
47
- });
48
- });
@@ -1,64 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import Tiers from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- jest.mock("./connector", () => cmp => cmp);
6
- describe('<Tiers />', () => {
7
- describe('Rendering with data', () => {
8
- it('should render tier prices when tier prices are available', () => {
9
- const price = {
10
- tiers: [{
11
- from: 1,
12
- to: 2,
13
- unitPrice: 92.5
14
- }, {
15
- from: 3,
16
- to: 5,
17
- unitPrice: 77.5
18
- }, {
19
- from: 6,
20
- to: null,
21
- unitPrice: 68.5
22
- }],
23
- currency: 'USD'
24
- };
25
- const wrapper = shallow(/*#__PURE__*/_jsx(Tiers, {
26
- price: price
27
- }));
28
- expect(wrapper).toMatchSnapshot();
29
- });
30
- });
31
- describe('Rendering without data', () => {
32
- it('should render nothing when price data are not available ({})', () => {
33
- const wrapper = shallow(/*#__PURE__*/_jsx(Tiers, {
34
- price: {}
35
- }));
36
- expect(wrapper).toBeEmptyRender();
37
- });
38
- it('should render nothing when price data are not available (null)', () => {
39
- const wrapper = shallow(/*#__PURE__*/_jsx(Tiers, {
40
- price: null
41
- }));
42
- expect(wrapper).toBeEmptyRender();
43
- });
44
- it('should render nothing when tier prices are empty ([])', () => {
45
- const price = {
46
- tiers: [],
47
- currency: 'USD'
48
- };
49
- const wrapper = shallow(/*#__PURE__*/_jsx(Tiers, {
50
- price: price
51
- }));
52
- expect(wrapper).toBeEmptyRender();
53
- });
54
- it('should render nothing when tier prices are not available (field missing)', () => {
55
- const price = {
56
- currency: 'USD'
57
- };
58
- const wrapper = shallow(/*#__PURE__*/_jsx(Tiers, {
59
- price: price
60
- }));
61
- expect(wrapper).toBeEmptyRender();
62
- });
63
- });
64
- });