@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.
- package/mocks/date.js +31 -0
- package/mocks/index.js +3 -0
- package/mocks/pipelineRequest.js +1 -0
- package/mocks/subscriptions.js +1 -0
- package/package.json +7 -7
- package/product/selectors/mocks/productProperties.mock.js +49 -0
- package/components/ChipLayout/spec.js +0 -41
- package/components/Logo/spec.js +0 -12
- package/components/NavigationHandler/spec.js +0 -84
- package/components/Picker/spec.js +0 -87
- package/components/PickerUtilize/spec.js +0 -32
- package/components/RangeSlider/spec.js +0 -190
- package/components/SheetList/components/Item/spec.js +0 -101
- package/components/SheetList/spec.js +0 -43
- package/components/TimeBoundary/spec.js +0 -83
- package/filter/components/FilterItem/spec.js +0 -14
- package/filter/components/FilterPageContent/components/ApplyButton/spec.js +0 -46
- package/filter/components/FilterPageContent/components/ResetButton/spec.js +0 -29
- package/filter/components/FilterPageContent/components/Selector/components/Selected/spec.js +0 -26
- package/filter/components/FilterPageContent/components/Selector/components/Toggle/spec.js +0 -34
- package/filter/components/FilterPageContent/components/Selector/components/ValueButton/spec.js +0 -32
- package/filter/components/FilterPageContent/components/Selector/spec.js +0 -33
- package/filter/components/PriceSlider/components/Label/spec.js +0 -17
- package/filter/components/PriceSlider/spec.js +0 -25
- package/product/components/FilterBar/components/Content/spec.js +0 -136
- package/product/components/Header/Shipping/spec.js +0 -37
- package/product/components/Header/Tiers/components/Tier/spec.js +0 -48
- package/product/components/Header/Tiers/spec.js +0 -64
- package/product/components/Options/components/Content/spec.js +0 -73
- package/product/components/Options/components/TextOption/components/OptionInfo/spec.js +0 -63
- package/product/components/ProductDiscountBadge/spec.js +0 -58
- package/product/components/ProductGrid/components/Item/components/ItemDetails/spec.js +0 -73
- package/product/components/ProductGrid/components/Item/components/ItemFavoritesButton/spec.js +0 -33
- package/product/components/ProductGrid/components/Item/components/ItemImage/spec.js +0 -16
- package/product/components/ProductGrid/components/Item/components/ItemName/spec.js +0 -21
- package/product/components/ProductGrid/components/Item/components/ItemPrice/spec.js +0 -37
- package/product/components/ProductGrid/spec.js +0 -52
- package/product/components/ProductImage/spec.js +0 -87
- package/product/components/ProductSlider/spec.js +0 -37
- package/product/components/Rating/spec.js +0 -57
- package/reviews/components/Reviews/components/Header/components/WriteReviewLink/spec.js +0 -35
- package/reviews/components/Reviews/components/Header/spec.js +0 -60
- package/reviews/components/Reviews/components/List/spec.js +0 -69
- package/reviews/components/Reviews/components/RatingCount/spec.js +0 -18
- package/reviews/components/Reviews/spec.js +0 -73
- package/tsconfig.build.json +0 -26
- package/tsconfig.json +0 -18
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount, shallow } from 'enzyme';
|
|
3
|
-
import { PickerUtilize as Picker } from '@shopgate/engage/components';
|
|
4
|
-
import Options from "./index";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
jest.mock('@shopgate/engage/components');
|
|
7
|
-
jest.mock('@shopgate/engage/product/components', () => ({
|
|
8
|
-
PriceDifference: () => null
|
|
9
|
-
}));
|
|
10
|
-
jest.mock('@shopgate/engage/product/contexts', () => {
|
|
11
|
-
const ReactCopy = jest.requireActual('react');
|
|
12
|
-
return {
|
|
13
|
-
ProductContext: ReactCopy.createContext({
|
|
14
|
-
setOption: jest.fn(),
|
|
15
|
-
currency: 'EUR'
|
|
16
|
-
})
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Mock the redux connect() method instead of providing a fake store.
|
|
21
|
-
jest.mock("./connector", () => obj => {
|
|
22
|
-
const newObj = obj;
|
|
23
|
-
const mockOptions = [{
|
|
24
|
-
id: 'test-id',
|
|
25
|
-
type: 'select',
|
|
26
|
-
label: 'label',
|
|
27
|
-
items: [{
|
|
28
|
-
currency: 'USD',
|
|
29
|
-
price: 10,
|
|
30
|
-
priceDifference: 0
|
|
31
|
-
}, {
|
|
32
|
-
currency: 'USD',
|
|
33
|
-
price: 10,
|
|
34
|
-
priceDifference: 0
|
|
35
|
-
}]
|
|
36
|
-
}];
|
|
37
|
-
newObj.defaultProps = {
|
|
38
|
-
options: mockOptions,
|
|
39
|
-
currentOptions: {}
|
|
40
|
-
};
|
|
41
|
-
return newObj;
|
|
42
|
-
});
|
|
43
|
-
describe('<Options />', () => {
|
|
44
|
-
const mockOptions = [{
|
|
45
|
-
id: 'test-id',
|
|
46
|
-
type: 'select',
|
|
47
|
-
label: 'label',
|
|
48
|
-
items: [{
|
|
49
|
-
currency: 'USD',
|
|
50
|
-
price: 10,
|
|
51
|
-
priceDifference: 0
|
|
52
|
-
}, {
|
|
53
|
-
currency: 'USD',
|
|
54
|
-
price: 10,
|
|
55
|
-
priceDifference: 0
|
|
56
|
-
}]
|
|
57
|
-
}];
|
|
58
|
-
describe('Given the component was mounted to the DOM', () => {
|
|
59
|
-
it('should match snapshot', () => {
|
|
60
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Options, {
|
|
61
|
-
currentOptions: {}
|
|
62
|
-
})).dive();
|
|
63
|
-
expect(wrapper).toMatchSnapshot();
|
|
64
|
-
});
|
|
65
|
-
it('should render correct number of options', () => {
|
|
66
|
-
const wrapper = mount(/*#__PURE__*/_jsx(Options, {
|
|
67
|
-
options: mockOptions
|
|
68
|
-
}));
|
|
69
|
-
const picker = wrapper.find(Picker);
|
|
70
|
-
expect(picker.length).toBe(mockOptions.length);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
|
|
4
|
-
import { OptionInfo } from "./index";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const optionInfoText = 'Some Text';
|
|
7
|
-
const optionInfoId = 'some-id';
|
|
8
|
-
jest.mock('@shopgate/engage/components', () => {
|
|
9
|
-
const {
|
|
10
|
-
default: Grid
|
|
11
|
-
} = jest.requireActual('@shopgate/pwa-common/components/Grid');
|
|
12
|
-
const {
|
|
13
|
-
default: I18n
|
|
14
|
-
} = jest.requireActual('@shopgate/pwa-common/components/I18n');
|
|
15
|
-
return {
|
|
16
|
-
Grid,
|
|
17
|
-
I18n
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
jest.mock('@shopgate/engage/product/contexts', () => ({
|
|
21
|
-
ProductContext: {
|
|
22
|
-
Consumer: ({
|
|
23
|
-
children
|
|
24
|
-
}) => children({
|
|
25
|
-
currency: 'EUR'
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
}));
|
|
29
|
-
describe('<OptionInfo />', () => {
|
|
30
|
-
it('should not render when not required and no price', () => {
|
|
31
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(OptionInfo, {
|
|
32
|
-
required: false,
|
|
33
|
-
label: "",
|
|
34
|
-
price: 0,
|
|
35
|
-
currency: "EUR",
|
|
36
|
-
info: optionInfoText,
|
|
37
|
-
optionInfoId: optionInfoId
|
|
38
|
-
}), mockRenderOptions);
|
|
39
|
-
expect(wrapper).toBeEmptyRender();
|
|
40
|
-
});
|
|
41
|
-
it('should render required element', () => {
|
|
42
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(OptionInfo, {
|
|
43
|
-
required: true,
|
|
44
|
-
label: "",
|
|
45
|
-
price: 0,
|
|
46
|
-
currency: "EUR",
|
|
47
|
-
info: optionInfoText,
|
|
48
|
-
optionInfoId: optionInfoId
|
|
49
|
-
}), mockRenderOptions).dive();
|
|
50
|
-
expect(wrapper).toMatchSnapshot();
|
|
51
|
-
});
|
|
52
|
-
it('should render price element', () => {
|
|
53
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(OptionInfo, {
|
|
54
|
-
required: false,
|
|
55
|
-
label: "Label",
|
|
56
|
-
price: 10,
|
|
57
|
-
currency: "EUR",
|
|
58
|
-
info: optionInfoText,
|
|
59
|
-
optionInfoId: optionInfoId
|
|
60
|
-
}), mockRenderOptions).dive();
|
|
61
|
-
expect(wrapper).toMatchSnapshot();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount } from 'enzyme';
|
|
3
|
-
import configureStore from 'redux-mock-store';
|
|
4
|
-
import { Provider } from 'react-redux';
|
|
5
|
-
import { useWidgetSettings } from '@shopgate/engage/core/hooks/useWidgetSettings';
|
|
6
|
-
import { mockedProduct1, mockedStateWithDiscount, mockedStateWithoutDiscount } from "./mock";
|
|
7
|
-
import ProductDiscountBadge from "./index";
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
jest.mock('@shopgate/engage/components');
|
|
10
|
-
jest.mock('@shopgate/engage/core/hooks/useWidgetSettings', () => ({
|
|
11
|
-
useWidgetSettings: jest.fn()
|
|
12
|
-
}));
|
|
13
|
-
describe('<ProductDiscountBadge />', () => {
|
|
14
|
-
const mockedStore = configureStore();
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
useWidgetSettings.mockReturnValue({
|
|
17
|
-
pdp: {
|
|
18
|
-
show: true,
|
|
19
|
-
style: {
|
|
20
|
-
color: 'blue'
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* createComponent
|
|
28
|
-
* @param {Object} mockedState mockedState
|
|
29
|
-
* @return {*}
|
|
30
|
-
*/
|
|
31
|
-
const createComponent = mockedState => {
|
|
32
|
-
const store = mockedStore(mockedState);
|
|
33
|
-
return mount(/*#__PURE__*/_jsx(Provider, {
|
|
34
|
-
store: store,
|
|
35
|
-
children: /*#__PURE__*/_jsx(ProductDiscountBadge, {
|
|
36
|
-
productId: mockedProduct1.productId
|
|
37
|
-
})
|
|
38
|
-
}));
|
|
39
|
-
};
|
|
40
|
-
it('should render without discount', () => {
|
|
41
|
-
const wrapper = createComponent(mockedStateWithoutDiscount);
|
|
42
|
-
expect(wrapper).toMatchSnapshot();
|
|
43
|
-
});
|
|
44
|
-
it('should render with discount', () => {
|
|
45
|
-
const wrapper = createComponent(mockedStateWithDiscount);
|
|
46
|
-
expect(wrapper).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
it('should not render with discount if widgetSetting is false', () => {
|
|
49
|
-
useWidgetSettings.mockReturnValue({
|
|
50
|
-
pdp: {
|
|
51
|
-
show: false,
|
|
52
|
-
style: {}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const wrapper = createComponent(mockedStateWithDiscount);
|
|
56
|
-
expect(wrapper).toMatchSnapshot();
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { hasNewServices } from '@shopgate/engage/core/helpers';
|
|
4
|
-
import { Availability } from '@shopgate/engage/components';
|
|
5
|
-
import { StockInfoLists } from '@shopgate/engage/locations/components';
|
|
6
|
-
import ItemDetails from "./index";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
jest.mock('@shopgate/engage/product', () => ({
|
|
9
|
-
MapPriceHint: () => null,
|
|
10
|
-
OrderQuantityHint: () => null,
|
|
11
|
-
EffectivityDates: () => null,
|
|
12
|
-
Swatches: () => null,
|
|
13
|
-
AVAILABILITY_STATE_OK: 'AVAILABILITY_STATE_OK',
|
|
14
|
-
AVAILABILITY_STATE_ALERT: 'AVAILABILITY_STATE_ALERT',
|
|
15
|
-
getProductRoute: jest.fn(productId => `link-to-product/${productId}`)
|
|
16
|
-
}));
|
|
17
|
-
jest.mock('@shopgate/engage/locations/components', () => ({
|
|
18
|
-
StockInfoLists: () => null
|
|
19
|
-
}));
|
|
20
|
-
jest.mock('@shopgate/engage/core/helpers', () => ({
|
|
21
|
-
hasNewServices: jest.fn().mockReturnValue(false),
|
|
22
|
-
i18n: {
|
|
23
|
-
text: str => str
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
26
|
-
jest.mock('@shopgate/engage/components');
|
|
27
|
-
jest.mock('@shopgate/engage/core', () => ({
|
|
28
|
-
isIOSTheme: jest.fn().mockReturnValue(true),
|
|
29
|
-
hasWebBridge: jest.fn().mockReturnValue(false),
|
|
30
|
-
i18n: {
|
|
31
|
-
text: text => text
|
|
32
|
-
}
|
|
33
|
-
}));
|
|
34
|
-
jest.mock("../ItemName");
|
|
35
|
-
jest.mock("../ItemPrice");
|
|
36
|
-
describe('<ItemDetails />', () => {
|
|
37
|
-
const props = {
|
|
38
|
-
product: {
|
|
39
|
-
id: '1234',
|
|
40
|
-
name: 'Foo',
|
|
41
|
-
price: {}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const display = {
|
|
45
|
-
name: false,
|
|
46
|
-
price: false,
|
|
47
|
-
reviews: false
|
|
48
|
-
};
|
|
49
|
-
it('should render with minimal props', () => {
|
|
50
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ItemDetails, {
|
|
51
|
-
...props
|
|
52
|
-
}));
|
|
53
|
-
expect(wrapper).toMatchSnapshot();
|
|
54
|
-
expect(wrapper.find(Availability).exists()).toBe(false);
|
|
55
|
-
expect(wrapper.find(StockInfoLists).exists()).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
it('should render additional components with new services', () => {
|
|
58
|
-
hasNewServices.mockReturnValueOnce(true);
|
|
59
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ItemDetails, {
|
|
60
|
-
...props
|
|
61
|
-
}));
|
|
62
|
-
expect(wrapper).toMatchSnapshot();
|
|
63
|
-
expect(wrapper.find(Availability).exists()).toBe(true);
|
|
64
|
-
expect(wrapper.find(StockInfoLists).exists()).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
it('should not render with display props set', () => {
|
|
67
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ItemDetails, {
|
|
68
|
-
...props,
|
|
69
|
-
display: display
|
|
70
|
-
}));
|
|
71
|
-
expect(wrapper).toBeEmptyRender();
|
|
72
|
-
});
|
|
73
|
-
});
|
package/product/components/ProductGrid/components/Item/components/ItemFavoritesButton/spec.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { combineReducers } from 'redux';
|
|
4
|
-
import { Provider } from 'react-redux';
|
|
5
|
-
import { createMockStore } from '@shopgate/pwa-common/store';
|
|
6
|
-
import favorites from '@shopgate/pwa-common-commerce/favorites/reducers';
|
|
7
|
-
import ItemFavoritesButton from "./index";
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
jest.mock('@shopgate/engage/components');
|
|
10
|
-
const store = createMockStore(combineReducers({
|
|
11
|
-
favorites
|
|
12
|
-
}));
|
|
13
|
-
describe('<ItemFavoritesButton />', () => {
|
|
14
|
-
it('should not render when its not a favorite', () => {
|
|
15
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Provider, {
|
|
16
|
-
store: store,
|
|
17
|
-
children: /*#__PURE__*/_jsx(ItemFavoritesButton, {
|
|
18
|
-
productId: "1234"
|
|
19
|
-
})
|
|
20
|
-
}));
|
|
21
|
-
expect(wrapper).toMatchSnapshot();
|
|
22
|
-
});
|
|
23
|
-
it('should render if its a favorite', () => {
|
|
24
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Provider, {
|
|
25
|
-
store: store,
|
|
26
|
-
children: /*#__PURE__*/_jsx(ItemFavoritesButton, {
|
|
27
|
-
productId: "1234",
|
|
28
|
-
isFavorite: true
|
|
29
|
-
})
|
|
30
|
-
}));
|
|
31
|
-
expect(wrapper).toMatchSnapshot();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import ItemImage from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
jest.mock('@shopgate/engage/components');
|
|
6
|
-
jest.mock('@shopgate/engage/product');
|
|
7
|
-
describe('<ItemImage />', () => {
|
|
8
|
-
it('should render', () => {
|
|
9
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ItemImage, {
|
|
10
|
-
productId: "1234",
|
|
11
|
-
imageUrl: "http://www.google.com",
|
|
12
|
-
name: "FooBar"
|
|
13
|
-
}));
|
|
14
|
-
expect(wrapper).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import ItemName from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
jest.mock('@shopgate/engage/product', () => ({
|
|
6
|
-
ProductName: () => null,
|
|
7
|
-
ProductRatingStars: () => null
|
|
8
|
-
}));
|
|
9
|
-
jest.mock('@shopgate/engage/components');
|
|
10
|
-
const props = {
|
|
11
|
-
productId: '1234',
|
|
12
|
-
name: 'Foo'
|
|
13
|
-
};
|
|
14
|
-
describe('<ItemName />', () => {
|
|
15
|
-
it('should render with minimal props', () => {
|
|
16
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ItemName, {
|
|
17
|
-
...props
|
|
18
|
-
}));
|
|
19
|
-
expect(wrapper).toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import ItemPrice from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
jest.mock('@shopgate/engage/product', () => ({
|
|
6
|
-
ProductGridPrice: () => null
|
|
7
|
-
}));
|
|
8
|
-
jest.mock('@shopgate/engage/components');
|
|
9
|
-
jest.mock('@shopgate/engage/category', () => ({
|
|
10
|
-
PRODUCT_ITEM_PRICE: 'PRODUCT_ITEM_PRICE',
|
|
11
|
-
PRODUCT_ITEM_PRICE_AFTER: 'PRODUCT_ITEM_PRICE_AFTER',
|
|
12
|
-
PRODUCT_ITEM_PRICE_BEFORE: 'PRODUCT_ITEM_PRICE_BEFORE'
|
|
13
|
-
}));
|
|
14
|
-
const props = {
|
|
15
|
-
product: {
|
|
16
|
-
id: '1234',
|
|
17
|
-
price: {}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const display = {
|
|
21
|
-
price: false
|
|
22
|
-
};
|
|
23
|
-
describe('<ItemPrice />', () => {
|
|
24
|
-
it('should render with minimal props', () => {
|
|
25
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ItemPrice, {
|
|
26
|
-
...props
|
|
27
|
-
}));
|
|
28
|
-
expect(wrapper).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
it('should not render with display props set', () => {
|
|
31
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ItemPrice, {
|
|
32
|
-
...props,
|
|
33
|
-
display: display
|
|
34
|
-
}));
|
|
35
|
-
expect(wrapper).toBeEmptyRender();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount } from 'enzyme';
|
|
3
|
-
import ProductGrid from '.';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
global.console.error = jest.fn();
|
|
6
|
-
jest.mock('@shopgate/engage/core', () => ({
|
|
7
|
-
hasWebBridge: jest.fn(() => false),
|
|
8
|
-
isIOSTheme: jest.fn(() => false),
|
|
9
|
-
withForwardedRef: jest.fn(),
|
|
10
|
-
withCurrentProduct: jest.fn(),
|
|
11
|
-
useWidgetSettings: jest.fn().mockReturnValue({})
|
|
12
|
-
}));
|
|
13
|
-
jest.mock('@shopgate/engage/components', () => {
|
|
14
|
-
const {
|
|
15
|
-
ViewContext
|
|
16
|
-
} = jest.requireActual('@shopgate/engage/components/View/context');
|
|
17
|
-
return {
|
|
18
|
-
ViewContext,
|
|
19
|
-
InfiniteContainer: () => null,
|
|
20
|
-
Grid: () => null
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
jest.mock("./components/Iterator", () => function Iterator() {
|
|
24
|
-
return null;
|
|
25
|
-
});
|
|
26
|
-
jest.mock('@shopgate/engage/product', () => ({
|
|
27
|
-
ProductListTypeProvider: ({
|
|
28
|
-
children
|
|
29
|
-
}) => children,
|
|
30
|
-
ProductListEntryProvider: ({
|
|
31
|
-
children
|
|
32
|
-
}) => children
|
|
33
|
-
}));
|
|
34
|
-
describe('<ProductGrid />', () => {
|
|
35
|
-
it('should render with the InfiniteContainer', () => {
|
|
36
|
-
const wrapper = mount(/*#__PURE__*/_jsx(ProductGrid, {
|
|
37
|
-
products: []
|
|
38
|
-
}));
|
|
39
|
-
expect(wrapper).toMatchSnapshot();
|
|
40
|
-
expect(wrapper.find('InfiniteContainer').exists()).toBe(true);
|
|
41
|
-
expect(wrapper.find('Layout').exists()).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
it('should render the original layout', () => {
|
|
44
|
-
const wrapper = mount(/*#__PURE__*/_jsx(ProductGrid, {
|
|
45
|
-
infiniteLoad: false,
|
|
46
|
-
products: []
|
|
47
|
-
}));
|
|
48
|
-
expect(wrapper).toMatchSnapshot();
|
|
49
|
-
expect(wrapper.find('InfiniteContainer').exists()).toBe(false);
|
|
50
|
-
expect(wrapper.find('Layout').exists()).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import Image from '@shopgate/pwa-common/components/Image';
|
|
4
|
-
import appConfig from '@shopgate/pwa-common/helpers/config';
|
|
5
|
-
import PlaceholderIcon from '@shopgate/pwa-ui-shared/icons/PlaceholderIcon';
|
|
6
|
-
import ProductImagePlaceholder from "./ProductImagePlaceholder";
|
|
7
|
-
import ProductImage from "./index";
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
jest.unmock('@shopgate/pwa-core');
|
|
10
|
-
jest.mock("../../../core/hocs/withWidgetSettings");
|
|
11
|
-
jest.mock('@shopgate/pwa-common/helpers/config');
|
|
12
|
-
jest.mock("./connector", () => Component => Component);
|
|
13
|
-
jest.mock('@shopgate/engage/components', () => ({
|
|
14
|
-
Image: () => null
|
|
15
|
-
}));
|
|
16
|
-
describe('<ProductImage />', () => {
|
|
17
|
-
it('should render a placeholder if no src prop is provided', () => {
|
|
18
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ProductImage, {})).dive();
|
|
19
|
-
expect(wrapper).toMatchSnapshot();
|
|
20
|
-
expect(wrapper.find(Image).length).toBe(0);
|
|
21
|
-
expect(wrapper.find(PlaceholderIcon).length).toBe(1);
|
|
22
|
-
});
|
|
23
|
-
it('should render the image without a placeholder', () => {
|
|
24
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ProductImage, {
|
|
25
|
-
src: "http://placehold.it/300x300"
|
|
26
|
-
})).dive();
|
|
27
|
-
expect(wrapper).toMatchSnapshot();
|
|
28
|
-
expect(wrapper.find(Image).length).toBe(1);
|
|
29
|
-
expect(wrapper.find(PlaceholderIcon).length).toBe(0);
|
|
30
|
-
});
|
|
31
|
-
it('should not apply an inner shadow to the placeholder if turned off via the app config', () => {
|
|
32
|
-
jest.spyOn(appConfig, 'hideProductImageShadow', 'get').mockReturnValue(true);
|
|
33
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ProductImage, {
|
|
34
|
-
placeholderSrc: "http://placehold.it/300x300"
|
|
35
|
-
})).dive();
|
|
36
|
-
expect(wrapper).toMatchSnapshot();
|
|
37
|
-
expect(wrapper.find(ProductImagePlaceholder).prop('showInnerShadow')).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
it('should not apply an inner shadow to the image if turned off via the app config', () => {
|
|
40
|
-
jest.spyOn(appConfig, 'hideProductImageShadow', 'get').mockReturnValue(true);
|
|
41
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ProductImage, {
|
|
42
|
-
src: "http://placehold.it/300x300"
|
|
43
|
-
})).dive();
|
|
44
|
-
expect(wrapper).toMatchSnapshot();
|
|
45
|
-
expect(wrapper.find(Image).prop('className')).toBe('');
|
|
46
|
-
});
|
|
47
|
-
it('should not apply an inner shadow to the placeholder if turned off via the widget settings', () => {
|
|
48
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ProductImage, {
|
|
49
|
-
placeholderSrc: "http://placehold.it/300x300",
|
|
50
|
-
widgetSettings: {
|
|
51
|
-
showInnerShadow: false
|
|
52
|
-
}
|
|
53
|
-
})).dive();
|
|
54
|
-
expect(wrapper).toMatchSnapshot();
|
|
55
|
-
expect(wrapper.find(ProductImagePlaceholder).prop('showInnerShadow')).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
it('should not apply an inner shadow to the image if turned off via the widget settings', () => {
|
|
58
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ProductImage, {
|
|
59
|
-
src: "http://placehold.it/300x300",
|
|
60
|
-
widgetSettings: {
|
|
61
|
-
showInnerShadow: false
|
|
62
|
-
}
|
|
63
|
-
})).dive();
|
|
64
|
-
expect(wrapper).toMatchSnapshot();
|
|
65
|
-
expect(wrapper.find(Image).prop('className')).toBe('');
|
|
66
|
-
});
|
|
67
|
-
it('should apply an inner shadow to the placeholder if turned off via the widget settings', () => {
|
|
68
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ProductImage, {
|
|
69
|
-
widgetSettings: {
|
|
70
|
-
showInnerShadow: true
|
|
71
|
-
},
|
|
72
|
-
placeholderSrc: "http://placehold.it/300x300"
|
|
73
|
-
})).dive();
|
|
74
|
-
expect(wrapper).toMatchSnapshot();
|
|
75
|
-
expect(wrapper.find(ProductImagePlaceholder).prop('showInnerShadow')).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
it('should apply an inner shadow to the image if turned off via the widget settings', () => {
|
|
78
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ProductImage, {
|
|
79
|
-
src: "http://placehold.it/300x300",
|
|
80
|
-
widgetSettings: {
|
|
81
|
-
showInnerShadow: true
|
|
82
|
-
}
|
|
83
|
-
})).dive();
|
|
84
|
-
expect(wrapper).toMatchSnapshot();
|
|
85
|
-
expect(wrapper.find(Image).prop('className')).toBeTruthy();
|
|
86
|
-
});
|
|
87
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import ProductSlider from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
jest.mock('@shopgate/engage/core', () => ({
|
|
6
|
-
useWidgetSettings: jest.fn()
|
|
7
|
-
}));
|
|
8
|
-
jest.mock('@shopgate/engage/components', () => {
|
|
9
|
-
const Swiper = ({
|
|
10
|
-
children
|
|
11
|
-
}) => children;
|
|
12
|
-
Swiper.Item = ({
|
|
13
|
-
children
|
|
14
|
-
}) => children;
|
|
15
|
-
Swiper.Item.displayName = 'Swiper.Item';
|
|
16
|
-
return {
|
|
17
|
-
Swiper
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
jest.mock('@shopgate/engage/core/hooks', () => {
|
|
21
|
-
const ProductCard = props => /*#__PURE__*/_jsx(ProductCard, {
|
|
22
|
-
...props
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
useThemeComponents: () => ({
|
|
26
|
-
ProductCard
|
|
27
|
-
})
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
describe('<ProductSlider />', () => {
|
|
31
|
-
it('should match snapshot', () => {
|
|
32
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ProductSlider, {
|
|
33
|
-
productIds: ['prod1']
|
|
34
|
-
}));
|
|
35
|
-
expect(wrapper).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Provider } from 'react-redux';
|
|
3
|
-
import configureStore from 'redux-mock-store';
|
|
4
|
-
import { mount } from 'enzyme';
|
|
5
|
-
import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
|
|
6
|
-
import { setMocks, mockedStateWithTwoReviews, mockedStateWithoutReview } from '@shopgate/pwa-common-commerce/reviews/mock';
|
|
7
|
-
import Rating from "./index";
|
|
8
|
-
import { getElementById } from "./mock";
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
setMocks();
|
|
11
|
-
jest.mock('@shopgate/engage/components');
|
|
12
|
-
describe('Rating (product header)', () => {
|
|
13
|
-
const mockedStore = configureStore();
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Makes component.
|
|
17
|
-
* @param {Object} state State
|
|
18
|
-
* @returns {Object}
|
|
19
|
-
*/
|
|
20
|
-
const getComponent = state => mount(/*#__PURE__*/_jsx(Provider, {
|
|
21
|
-
store: mockedStore(state),
|
|
22
|
-
children: /*#__PURE__*/_jsx(Rating, {
|
|
23
|
-
productId: "foo"
|
|
24
|
-
})
|
|
25
|
-
}), mockRenderOptions);
|
|
26
|
-
describe('Rendering', () => {
|
|
27
|
-
it('should render rating when data is available', () => {
|
|
28
|
-
const component = getComponent(mockedStateWithTwoReviews);
|
|
29
|
-
expect(component).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
it('should render nothing when data is not available', () => {
|
|
32
|
-
const component = getComponent(mockedStateWithoutReview);
|
|
33
|
-
expect(component.isEmptyRender()).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe('Scroll on click', () => {
|
|
37
|
-
const scrollSpy = jest.fn();
|
|
38
|
-
it('should scroll to reviews when clicked', () => {
|
|
39
|
-
jest.spyOn(document, 'getElementById').mockImplementation(getElementById(scrollSpy));
|
|
40
|
-
const component = getComponent(mockedStateWithTwoReviews);
|
|
41
|
-
component.simulate('click');
|
|
42
|
-
expect(scrollSpy.mock.calls[0][0]).toBe(0);
|
|
43
|
-
expect(scrollSpy.mock.calls[0][1]).toBe(70);
|
|
44
|
-
expect(scrollSpy).toHaveBeenCalled();
|
|
45
|
-
document.getElementById.mockReset();
|
|
46
|
-
document.getElementById.mockRestore();
|
|
47
|
-
});
|
|
48
|
-
it('should do nothing when clicked but no reviews excerpt element', () => {
|
|
49
|
-
jest.spyOn(document, 'getElementById').mockImplementation(() => null);
|
|
50
|
-
const component = getComponent(mockedStateWithTwoReviews);
|
|
51
|
-
component.simulate('click');
|
|
52
|
-
expect(scrollSpy.mock.calls.length).toBe(1);
|
|
53
|
-
document.getElementById.mockReset();
|
|
54
|
-
document.getElementById.mockRestore();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Provider } from 'react-redux';
|
|
3
|
-
import configureStore from 'redux-mock-store';
|
|
4
|
-
import { mount } from 'enzyme';
|
|
5
|
-
import { mockedStateWithAll } from '@shopgate/pwa-common-commerce/reviews/mock';
|
|
6
|
-
import WriteReviewLink from "./index";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
const mockedStore = configureStore();
|
|
9
|
-
jest.mock('@shopgate/engage/components');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Creates component with provided store state.
|
|
13
|
-
* @param {Object} mockedState Mocked stage.
|
|
14
|
-
* @return {ReactWrapper}
|
|
15
|
-
*/
|
|
16
|
-
const createComponent = mockedState => {
|
|
17
|
-
const Component = /*#__PURE__*/_jsx(Provider, {
|
|
18
|
-
store: mockedStore(mockedState),
|
|
19
|
-
children: /*#__PURE__*/_jsx(WriteReviewLink, {
|
|
20
|
-
productId: "foo"
|
|
21
|
-
})
|
|
22
|
-
});
|
|
23
|
-
return mount(Component);
|
|
24
|
-
};
|
|
25
|
-
describe('<WriteReviewLink>', () => {
|
|
26
|
-
let component = null;
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
jest.resetModules();
|
|
29
|
-
});
|
|
30
|
-
it('should render when current product is set', () => {
|
|
31
|
-
component = createComponent(mockedStateWithAll);
|
|
32
|
-
expect(component).toMatchSnapshot();
|
|
33
|
-
expect(component.find('Text[string="reviews.button_add"]').exists()).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
});
|