@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,60 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Provider } from 'react-redux';
|
|
3
|
-
import { mount } from 'enzyme';
|
|
4
|
-
import configureStore from 'redux-mock-store';
|
|
5
|
-
import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
|
|
6
|
-
import { mockProductId, mockedStateWithoutReview, mockedStateWithAll } from '@shopgate/pwa-common-commerce/reviews/mock';
|
|
7
|
-
import Header from "./index";
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
const mockedStore = configureStore();
|
|
10
|
-
jest.mock('@shopgate/engage/components');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Creates component with provided store state.
|
|
14
|
-
* @param {Object} mockedState Mocked stage.
|
|
15
|
-
* @param {Object|null} props Rating prop.
|
|
16
|
-
* @return {ReactWrapper}
|
|
17
|
-
*/
|
|
18
|
-
const createComponent = (mockedState, props = {}) => mount(/*#__PURE__*/_jsx(Provider, {
|
|
19
|
-
store: mockedStore(mockedState),
|
|
20
|
-
children: /*#__PURE__*/_jsx(Header, {
|
|
21
|
-
...props
|
|
22
|
-
})
|
|
23
|
-
}), mockRenderOptions);
|
|
24
|
-
describe('<Header />', () => {
|
|
25
|
-
let header = null;
|
|
26
|
-
it('should render empty', () => {
|
|
27
|
-
const productId = mockProductId;
|
|
28
|
-
const {
|
|
29
|
-
rating
|
|
30
|
-
} = mockedStateWithoutReview.product.productsById[productId].productData;
|
|
31
|
-
header = createComponent(mockedStateWithoutReview, {
|
|
32
|
-
productId,
|
|
33
|
-
rating
|
|
34
|
-
});
|
|
35
|
-
expect(header.find('Header').exists()).toBe(true);
|
|
36
|
-
expect(header).toMatchSnapshot();
|
|
37
|
-
expect(header.find('RatingStars').prop('value')).toEqual(0);
|
|
38
|
-
expect(header.find('RatingCount').isEmptyRender()).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
it('should render rating summary', () => {
|
|
41
|
-
const productId = mockProductId;
|
|
42
|
-
const {
|
|
43
|
-
rating
|
|
44
|
-
} = mockedStateWithAll.product.productsById[productId].productData;
|
|
45
|
-
header = createComponent(mockedStateWithAll, {
|
|
46
|
-
productId,
|
|
47
|
-
rating
|
|
48
|
-
});
|
|
49
|
-
expect(header.find('Header').exists()).toBe(true);
|
|
50
|
-
expect(header).toMatchSnapshot();
|
|
51
|
-
expect(header.find('RatingStars').prop('value')).toEqual(rating.average);
|
|
52
|
-
expect(header.find('RatingCount').prop('count')).toEqual(rating.count);
|
|
53
|
-
});
|
|
54
|
-
it('should render null when no review is provided', () => {
|
|
55
|
-
header = createComponent(mockedStateWithAll, {
|
|
56
|
-
productId: 'some-id'
|
|
57
|
-
});
|
|
58
|
-
expect(header.isEmptyRender()).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount } from 'enzyme';
|
|
3
|
-
import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
|
|
4
|
-
import List from "./index";
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
jest.mock('@shopgate/engage/components');
|
|
7
|
-
describe('<List />', () => {
|
|
8
|
-
let list = null;
|
|
9
|
-
const reviews = [{
|
|
10
|
-
id: 'a',
|
|
11
|
-
author: '',
|
|
12
|
-
date: '2017-09-06T12:38:51.000Z',
|
|
13
|
-
rate: 100,
|
|
14
|
-
title: '',
|
|
15
|
-
review: 'No Name and Title Lorem ipsum dolor sit amet, con… takimata sanctus est Lorem ipsum dolor sit amet.'
|
|
16
|
-
}, {
|
|
17
|
-
id: 'b',
|
|
18
|
-
author: 'username123',
|
|
19
|
-
date: '2017-09-06T12:37:40.000Z',
|
|
20
|
-
rate: 40,
|
|
21
|
-
title: 'Test review 2 ',
|
|
22
|
-
review: 'Lorem ipsum dolor sit amet, consetetur sadipscing … takimata sanctus est Lorem ipsum dolor sit amet.'
|
|
23
|
-
}, {
|
|
24
|
-
id: 'c',
|
|
25
|
-
author: 'Carina Hoffmann',
|
|
26
|
-
date: '2017-09-06T12:30:23.000Z',
|
|
27
|
-
rate: 60,
|
|
28
|
-
title: '',
|
|
29
|
-
review: 'Test review'
|
|
30
|
-
}, {
|
|
31
|
-
id: 'd',
|
|
32
|
-
author: '',
|
|
33
|
-
date: '2017-09-06T12:30:23.000Z',
|
|
34
|
-
rate: 20,
|
|
35
|
-
title: '',
|
|
36
|
-
review: ''
|
|
37
|
-
}];
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
list = mount(/*#__PURE__*/_jsx(List, {
|
|
40
|
-
reviews: []
|
|
41
|
-
}), mockRenderOptions);
|
|
42
|
-
});
|
|
43
|
-
it('should not render when no reviews given', () => {
|
|
44
|
-
expect(list).toMatchSnapshot();
|
|
45
|
-
expect(list.find('Review').exists()).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
it('should render list with reviews', () => {
|
|
48
|
-
list.setProps({
|
|
49
|
-
reviews
|
|
50
|
-
});
|
|
51
|
-
expect(list).toMatchSnapshot();
|
|
52
|
-
expect(list.find('List > ul').exists()).toBe(true);
|
|
53
|
-
list.find('Review').forEach((node, i) => {
|
|
54
|
-
const ratingNode = node.find('Rating');
|
|
55
|
-
expect(ratingNode.prop('rate')).toEqual(reviews[i].rate);
|
|
56
|
-
expect(ratingNode.find('RatingStars').prop('value')).toEqual(reviews[i].rate);
|
|
57
|
-
expect(node.find('Info').prop('review').date).toEqual(reviews[i].date);
|
|
58
|
-
if (reviews[i].author) {
|
|
59
|
-
expect(node.find('Info').prop('review').author).toEqual(reviews[i].author);
|
|
60
|
-
}
|
|
61
|
-
if (reviews[i].title) {
|
|
62
|
-
expect(node.find('Title').prop('title')).toEqual(reviews[i].title);
|
|
63
|
-
}
|
|
64
|
-
if (reviews[i].review) {
|
|
65
|
-
expect(node.find('Text').prop('review')).toEqual(reviews[i].review);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount } from 'enzyme';
|
|
3
|
-
import RatingCount from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
describe('<RatingCount>', () => {
|
|
6
|
-
it('should render nothing when count is 0', () => {
|
|
7
|
-
const rating = mount(/*#__PURE__*/_jsx(RatingCount, {
|
|
8
|
-
count: 0
|
|
9
|
-
}));
|
|
10
|
-
expect(rating.find('span').exists()).toBe(false);
|
|
11
|
-
});
|
|
12
|
-
it('should render text when count is more than 0', () => {
|
|
13
|
-
const rating = mount(/*#__PURE__*/_jsx(RatingCount, {
|
|
14
|
-
count: 1
|
|
15
|
-
}));
|
|
16
|
-
expect(rating.find('span').exists()).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,73 +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 { mockedStateWithAll, mockedStateWithoutReview, mockedStateWithTwoReviews } from '@shopgate/pwa-common-commerce/reviews/mock';
|
|
7
|
-
import appConfig from '@shopgate/pwa-common/helpers/config';
|
|
8
|
-
import Reviews from "./index";
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
const mockedStore = configureStore();
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @returns {JSX}
|
|
14
|
-
*/
|
|
15
|
-
jest.mock("./components/Header", () => function Header() {
|
|
16
|
-
return /*#__PURE__*/_jsx("div", {});
|
|
17
|
-
});
|
|
18
|
-
jest.mock('@shopgate/engage/product', () => ({
|
|
19
|
-
PRODUCT_REVIEWS: 'product.reviews',
|
|
20
|
-
makeIsBaseProductActive: jest.fn(() => () => true)
|
|
21
|
-
}));
|
|
22
|
-
jest.mock('@shopgate/engage/components');
|
|
23
|
-
|
|
24
|
-
// Mock the getter of the hasReviews key inside the app config, so that we can turn it off later
|
|
25
|
-
jest.resetModules();
|
|
26
|
-
const hasReviewsGetter = jest.fn().mockReturnValue(true);
|
|
27
|
-
Object.defineProperty(appConfig, 'hasReviews', {
|
|
28
|
-
get: hasReviewsGetter
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Creates component with provided store state.
|
|
33
|
-
* @param {Object} mockedState Mocked stage.
|
|
34
|
-
* @return {ReactWrapper}
|
|
35
|
-
*/
|
|
36
|
-
const createComponent = mockedState => mount(/*#__PURE__*/_jsx(Provider, {
|
|
37
|
-
store: mockedStore(mockedState),
|
|
38
|
-
children: /*#__PURE__*/_jsx(Reviews, {
|
|
39
|
-
productId: "foo"
|
|
40
|
-
})
|
|
41
|
-
}), mockRenderOptions);
|
|
42
|
-
describe('<Reviews />', () => {
|
|
43
|
-
let component = null;
|
|
44
|
-
it('should render when no reviews and rating given', () => {
|
|
45
|
-
component = createComponent(mockedStateWithoutReview);
|
|
46
|
-
expect(component).toMatchSnapshot();
|
|
47
|
-
expect(component.find('Header').exists()).toBe(true);
|
|
48
|
-
expect(component.find('List').exists()).toBe(true);
|
|
49
|
-
expect(component.find('AllReviewsLink').exists()).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
it('should render reviews, header and all reviews link', () => {
|
|
52
|
-
component = createComponent(mockedStateWithAll);
|
|
53
|
-
expect(component).toMatchSnapshot();
|
|
54
|
-
expect(component.find('Header').exists()).toBe(true);
|
|
55
|
-
expect(component.find('List').exists()).toBe(true);
|
|
56
|
-
expect(component.find('AllReviewsLink').find('div').exists()).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
it('should render reviews, header, but no all reviews link', () => {
|
|
59
|
-
component = createComponent(mockedStateWithTwoReviews);
|
|
60
|
-
expect(component).toMatchSnapshot();
|
|
61
|
-
expect(component.find('Header').exists()).toBe(true);
|
|
62
|
-
expect(component.find('List').exists()).toBe(true);
|
|
63
|
-
expect(component.find('AllReviewsLink').find('div').exists()).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
it('should not render when feature flag is off', () => {
|
|
66
|
-
hasReviewsGetter.mockReturnValueOnce(false);
|
|
67
|
-
component = createComponent(mockedStateWithAll);
|
|
68
|
-
expect(component).toMatchSnapshot();
|
|
69
|
-
expect(component.find('Header').exists()).toBe(false);
|
|
70
|
-
expect(component.find('List').exists()).toBe(false);
|
|
71
|
-
expect(component.find('AllReviewsLink').exists()).toBe(false);
|
|
72
|
-
});
|
|
73
|
-
});
|
package/tsconfig.build.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"removeComments": false,
|
|
6
|
-
"emitDeclarationOnly": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"rootDir": ".",
|
|
10
|
-
"noEmit": false,
|
|
11
|
-
"stripInternal": false,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"paths": {
|
|
14
|
-
"tss-react/tools/*": ["../../node_modules/tss-react/tools/*"]
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"include": ["**/*.ts", "**/*.tsx"],
|
|
18
|
-
"exclude": [
|
|
19
|
-
"dist",
|
|
20
|
-
"node_modules",
|
|
21
|
-
"**/*.spec.*",
|
|
22
|
-
"**/__tests__/**",
|
|
23
|
-
"**/__snapshots__/**",
|
|
24
|
-
"coverage"
|
|
25
|
-
]
|
|
26
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2019",
|
|
4
|
-
"lib": ["DOM", "ES2019"],
|
|
5
|
-
"module": "esnext",
|
|
6
|
-
"moduleResolution": "bundler",
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
|
|
9
|
-
"strict": true,
|
|
10
|
-
"isolatedModules": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
|
|
13
|
-
"allowJs": true,
|
|
14
|
-
"checkJs": false,
|
|
15
|
-
"noEmit": true
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|