@shopgate/pwa-ui-shared 7.32.0-beta.1 → 7.32.0-beta.11
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/ActionButton/index.js +4 -0
- package/AddToCartButton/index.js +4 -1
- package/Button/index.js +10 -3
- package/ButtonLink/index.js +4 -0
- package/Card/index.js +13 -34
- package/CardList/components/Item/index.js +26 -20
- package/CardList/index.js +2 -1
- package/CartTotalLine/index.js +1 -1
- package/Dialog/components/PipelineErrorDialog/index.js +2 -1
- package/Glow/index.js +4 -3
- package/NoResults/index.js +1 -1
- package/RatingStars/index.js +16 -5
- package/RippleButton/index.js +5 -1
- package/ScannerOverlay/components/ScannerBar/index.js +1 -1
- package/Sheet/components/Header/index.js +3 -4
- package/Sheet/index.js +15 -6
- package/TaxDisclaimer/index.js +0 -1
- package/icons/AccountBoxIcon.d.ts +1 -1
- package/icons/AccountBoxIcon.d.ts.map +1 -1
- package/icons/AddMoreIcon.d.ts +1 -1
- package/icons/AddMoreIcon.d.ts.map +1 -1
- package/icons/ArrowDropIcon.d.ts +1 -1
- package/icons/ArrowDropIcon.d.ts.map +1 -1
- package/icons/ArrowIcon.d.ts +1 -1
- package/icons/ArrowIcon.d.ts.map +1 -1
- package/icons/BarcodeScannerIcon.d.ts +1 -1
- package/icons/BarcodeScannerIcon.d.ts.map +1 -1
- package/icons/BoxIcon.d.ts +1 -1
- package/icons/BoxIcon.d.ts.map +1 -1
- package/icons/BrowseIcon.d.ts +2 -1
- package/icons/BrowseIcon.d.ts.map +1 -1
- package/icons/BurgerIcon.d.ts +1 -1
- package/icons/BurgerIcon.d.ts.map +1 -1
- package/icons/CalendarIcon.d.ts +2 -1
- package/icons/CalendarIcon.d.ts.map +1 -1
- package/icons/CartCouponIcon.d.ts +2 -1
- package/icons/CartCouponIcon.d.ts.map +1 -1
- package/icons/CartIcon.d.ts +2 -1
- package/icons/CartIcon.d.ts.map +1 -1
- package/icons/CartPlusIcon.d.ts +2 -1
- package/icons/CartPlusIcon.d.ts.map +1 -1
- package/icons/CheckIcon.d.ts +2 -1
- package/icons/CheckIcon.d.ts.map +1 -1
- package/icons/CheckedIcon.d.ts +1 -1
- package/icons/CheckedIcon.d.ts.map +1 -1
- package/icons/ChevronIcon.d.ts +2 -1
- package/icons/ChevronIcon.d.ts.map +1 -1
- package/icons/CreditCardIcon.d.ts +2 -1
- package/icons/CreditCardIcon.d.ts.map +1 -1
- package/icons/CrossIcon.d.ts +2 -1
- package/icons/CrossIcon.d.ts.map +1 -1
- package/icons/DescriptionIcon.d.ts +2 -1
- package/icons/DescriptionIcon.d.ts.map +1 -1
- package/icons/FilterIcon.d.ts +2 -1
- package/icons/FilterIcon.d.ts.map +1 -1
- package/icons/FlashDisabledIcon.d.ts +2 -1
- package/icons/FlashDisabledIcon.d.ts.map +1 -1
- package/icons/FlashEnabledIcon.d.ts +2 -1
- package/icons/FlashEnabledIcon.d.ts.map +1 -1
- package/icons/GridIcon.d.ts +2 -1
- package/icons/GridIcon.d.ts.map +1 -1
- package/icons/HeartIcon.d.ts +2 -1
- package/icons/HeartIcon.d.ts.map +1 -1
- package/icons/HeartOutlineIcon.d.ts +2 -1
- package/icons/HeartOutlineIcon.d.ts.map +1 -1
- package/icons/HeartPlusIcon.d.ts +2 -1
- package/icons/HeartPlusIcon.d.ts.map +1 -1
- package/icons/HeartPlusOutlineIcon.d.ts +2 -1
- package/icons/HeartPlusOutlineIcon.d.ts.map +1 -1
- package/icons/HomeIcon.d.ts +2 -1
- package/icons/HomeIcon.d.ts.map +1 -1
- package/icons/InfoIcon.d.ts +2 -1
- package/icons/InfoIcon.d.ts.map +1 -1
- package/icons/InfoOutlineIcon.d.ts +2 -1
- package/icons/InfoOutlineIcon.d.ts.map +1 -1
- package/icons/ListIcon.d.ts +2 -1
- package/icons/ListIcon.d.ts.map +1 -1
- package/icons/LocalShippingIcon.d.ts +2 -1
- package/icons/LocalShippingIcon.d.ts.map +1 -1
- package/icons/LocationIcon.d.ts +2 -1
- package/icons/LocationIcon.d.ts.map +1 -1
- package/icons/LocatorIcon.d.ts +2 -1
- package/icons/LocatorIcon.d.ts.map +1 -1
- package/icons/LockIcon.d.ts +2 -1
- package/icons/LockIcon.d.ts.map +1 -1
- package/icons/LogoutIcon.d.ts +2 -1
- package/icons/LogoutIcon.d.ts.map +1 -1
- package/icons/MagnifierIcon.d.ts +2 -1
- package/icons/MagnifierIcon.d.ts.map +1 -1
- package/icons/MapMarkerIcon.d.ts +2 -1
- package/icons/MapMarkerIcon.d.ts.map +1 -1
- package/icons/MoreIcon.d.ts +2 -1
- package/icons/MoreIcon.d.ts.map +1 -1
- package/icons/MoreVertIcon.d.ts +2 -1
- package/icons/MoreVertIcon.d.ts.map +1 -1
- package/icons/NotificationIcon.d.ts +2 -1
- package/icons/NotificationIcon.d.ts.map +1 -1
- package/icons/PersonIcon.d.ts +2 -1
- package/icons/PersonIcon.d.ts.map +1 -1
- package/icons/PhoneIcon.d.ts +2 -1
- package/icons/PhoneIcon.d.ts.map +1 -1
- package/icons/PlaceholderIcon.d.ts +2 -1
- package/icons/PlaceholderIcon.d.ts.map +1 -1
- package/icons/RadioCheckedIcon.d.ts +2 -1
- package/icons/RadioCheckedIcon.d.ts.map +1 -1
- package/icons/RadioUncheckedIcon.d.ts +2 -1
- package/icons/RadioUncheckedIcon.d.ts.map +1 -1
- package/icons/SecurityIcon.d.ts +2 -1
- package/icons/SecurityIcon.d.ts.map +1 -1
- package/icons/ShippingMethodIcon.d.ts +2 -1
- package/icons/ShippingMethodIcon.d.ts.map +1 -1
- package/icons/ShoppingCartIcon.d.ts +2 -1
- package/icons/ShoppingCartIcon.d.ts.map +1 -1
- package/icons/SortIcon.d.ts +2 -1
- package/icons/SortIcon.d.ts.map +1 -1
- package/icons/StarHalfIcon.d.ts +2 -1
- package/icons/StarHalfIcon.d.ts.map +1 -1
- package/icons/StarIcon.d.ts +2 -1
- package/icons/StarIcon.d.ts.map +1 -1
- package/icons/StarOutlineIcon.d.ts +2 -1
- package/icons/StarOutlineIcon.d.ts.map +1 -1
- package/icons/StopIcon.d.ts +2 -1
- package/icons/StopIcon.d.ts.map +1 -1
- package/icons/TickIcon.d.ts +2 -1
- package/icons/TickIcon.d.ts.map +1 -1
- package/icons/TimeIcon.d.ts +2 -1
- package/icons/TimeIcon.d.ts.map +1 -1
- package/icons/TrashIcon.d.ts +1 -1
- package/icons/TrashIcon.d.ts.map +1 -1
- package/icons/TrashOutlineIcon.d.ts +2 -1
- package/icons/TrashOutlineIcon.d.ts.map +1 -1
- package/icons/UncheckedIcon.d.ts +2 -1
- package/icons/UncheckedIcon.d.ts.map +1 -1
- package/icons/ViewListIcon.d.ts +2 -1
- package/icons/ViewListIcon.d.ts.map +1 -1
- package/icons/VisibilityIcon.d.ts +2 -1
- package/icons/VisibilityIcon.d.ts.map +1 -1
- package/icons/VisibilityOffIcon.d.ts +2 -1
- package/icons/VisibilityOffIcon.d.ts.map +1 -1
- package/icons/WarningIcon.d.ts +2 -1
- package/icons/WarningIcon.d.ts.map +1 -1
- package/package.json +5 -5
- package/AccordionContainer/spec.js +0 -35
- package/ActionButton/spec.js +0 -66
- package/AddToCartButton/spec.js +0 -68
- package/Availability/spec.js +0 -42
- package/Button/spec.js +0 -38
- package/ButtonLink/spec.js +0 -29
- package/Chip/spec.js +0 -27
- package/ContextMenu/spec.js +0 -113
- package/Dialog/components/HtmlContentDialog/spec.js +0 -107
- package/Dialog/components/PipelineErrorDialog/spec.js +0 -89
- package/Dialog/components/TextMessageDialog/spec.js +0 -62
- package/Dialog/components/VariantSelectModal/spec.js +0 -55
- package/Dialog/spec.js +0 -84
- package/DiscountBadge/spec.js +0 -20
- package/FavoritesButton/spec.js +0 -131
- package/Form/Builder/classes/ActionListener/spec.js +0 -323
- package/Form/Builder/spec.js +0 -309
- package/Form/InfoField/spec.js +0 -12
- package/Form/Password/spec.js +0 -39
- package/Form/RadioGroup/spec.js +0 -97
- package/Form/Select/spec.js +0 -39
- package/Form/SelectContextChoices/spec.js +0 -36
- package/Form/TextField/spec.js +0 -124
- package/FormElement/spec.js +0 -68
- package/Glow/spec.js +0 -14
- package/IndicatorCircle/spec.js +0 -26
- package/PlaceholderLabel/spec.js +0 -26
- package/PlaceholderParagraph/spec.js +0 -26
- package/ProgressBar/spec.js +0 -14
- package/RadioButton/spec.js +0 -22
- package/RatingStars/spec.js +0 -91
- package/RippleButton/spec.js +0 -58
- package/Sheet/components/Header/components/SearchBar/spec.js +0 -22
- package/Sheet/components/Header/spec.js +0 -17
- package/Sheet/spec.js +0 -100
- package/TaxDisclaimer/spec.js +0 -44
- package/TextField/spec.js +0 -146
- package/ToggleIcon/spec.js +0 -39
- package/tsconfig.build.json +0 -16
- package/tsconfig.json +0 -3
package/ContextMenu/spec.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount, shallow } from 'enzyme';
|
|
3
|
-
import { act } from 'react-dom/test-utils';
|
|
4
|
-
import Backdrop from '@shopgate/pwa-common/components/Backdrop';
|
|
5
|
-
import ContextMenu from "./index";
|
|
6
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
jest.mock('@shopgate/engage/components');
|
|
8
|
-
jest.mock('@shopgate/engage/a11y/components');
|
|
9
|
-
global.requestAnimationFrame = fn => fn();
|
|
10
|
-
jest.useFakeTimers();
|
|
11
|
-
describe('<ContextMenu />', () => {
|
|
12
|
-
const mockItemAClick = jest.fn();
|
|
13
|
-
const mockItemBClick = jest.fn();
|
|
14
|
-
const numMenuItems = 2;
|
|
15
|
-
describe('Snapshot test', () => {
|
|
16
|
-
it('should match snapshot', () => {
|
|
17
|
-
const wrapper = shallow(/*#__PURE__*/_jsxs(ContextMenu, {
|
|
18
|
-
isOpened: true,
|
|
19
|
-
children: [/*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
20
|
-
onClick: mockItemAClick,
|
|
21
|
-
className: "menu-active-item",
|
|
22
|
-
children: "Item A"
|
|
23
|
-
}), /*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
24
|
-
onClick: mockItemBClick,
|
|
25
|
-
className: "menu-active-item",
|
|
26
|
-
children: "Item B"
|
|
27
|
-
})]
|
|
28
|
-
}));
|
|
29
|
-
expect(wrapper).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
it('should match snapshot without toggle', () => {
|
|
32
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(ContextMenu, {
|
|
33
|
-
isOpened: true,
|
|
34
|
-
showToggle: false,
|
|
35
|
-
children: /*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
36
|
-
onClick: mockItemAClick,
|
|
37
|
-
className: "menu-active-item",
|
|
38
|
-
children: "Item A"
|
|
39
|
-
})
|
|
40
|
-
}));
|
|
41
|
-
expect(wrapper).toMatchSnapshot();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe('Given the component was mounted to the DOM', () => {
|
|
45
|
-
let renderedElement;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The view component
|
|
49
|
-
*/
|
|
50
|
-
const renderComponent = () => {
|
|
51
|
-
renderedElement = mount(/*#__PURE__*/_jsxs(ContextMenu, {
|
|
52
|
-
children: [/*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
53
|
-
onClick: mockItemAClick,
|
|
54
|
-
children: "Item A"
|
|
55
|
-
}), /*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
56
|
-
onClick: mockItemBClick,
|
|
57
|
-
children: "Item B"
|
|
58
|
-
})]
|
|
59
|
-
}));
|
|
60
|
-
};
|
|
61
|
-
beforeEach(renderComponent);
|
|
62
|
-
it('should match snapshot', () => {
|
|
63
|
-
expect(renderedElement).toMatchSnapshot();
|
|
64
|
-
});
|
|
65
|
-
it('should have active state set to false', () => {
|
|
66
|
-
expect(renderedElement.find('ConnectedReactPortal').prop('isOpened')).toBe(null);
|
|
67
|
-
});
|
|
68
|
-
it('should render the toggle button', () => {
|
|
69
|
-
expect(renderedElement.find('button').length).toBe(1);
|
|
70
|
-
});
|
|
71
|
-
it('should not render any context menu items', () => {
|
|
72
|
-
expect(renderedElement.find(ContextMenu.Item).length).toBe(0);
|
|
73
|
-
});
|
|
74
|
-
describe('Given toggle button gets clicked', () => {
|
|
75
|
-
beforeEach(() => {
|
|
76
|
-
renderedElement.find('button').simulate('click');
|
|
77
|
-
renderedElement.update();
|
|
78
|
-
});
|
|
79
|
-
it('should have active state set to true', () => {
|
|
80
|
-
expect(renderedElement.find('ConnectedReactPortal').prop('isOpened')).toBe(true);
|
|
81
|
-
});
|
|
82
|
-
it('should render the actual context menu w/ items', () => {
|
|
83
|
-
expect(renderedElement.find(ContextMenu.Item).length).toBe(numMenuItems);
|
|
84
|
-
});
|
|
85
|
-
describe('Given the first item gets clicked', () => {
|
|
86
|
-
beforeEach(() => {
|
|
87
|
-
act(() => {
|
|
88
|
-
renderedElement.find(ContextMenu.Item).first().children().find('[data-test-id="contextMenuButton"]').first().simulate('click');
|
|
89
|
-
jest.runAllTimers();
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
it('should call the related click handler', () => {
|
|
93
|
-
expect(mockItemAClick).toBeCalled();
|
|
94
|
-
});
|
|
95
|
-
it('should close the context menu', () => {
|
|
96
|
-
renderedElement.update();
|
|
97
|
-
expect(renderedElement.find(ContextMenu.Item).length).toBe(0);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
describe('Given the backdrop gets clicked', () => {
|
|
101
|
-
beforeEach(() => {
|
|
102
|
-
renderedElement.find(Backdrop).children().find('[onClick]').simulate('click');
|
|
103
|
-
});
|
|
104
|
-
it('should have active state reset to false', () => {
|
|
105
|
-
expect(renderedElement.find('ConnectedReactPortal').prop('isOpened')).toBe(false);
|
|
106
|
-
});
|
|
107
|
-
it('should close the context menu', () => {
|
|
108
|
-
expect(renderedElement.find(ContextMenu.Item).length).toBe(0);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import HtmlContentDialog from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const message = '<p><i>This is a html message.</i></p>';
|
|
6
|
-
const title = 'This is the title.';
|
|
7
|
-
jest.mock('@shopgate/engage/a11y/components');
|
|
8
|
-
jest.mock('@shopgate/engage/components', () => {
|
|
9
|
-
const mockReact = jest.requireActual('react');
|
|
10
|
-
function Text({
|
|
11
|
-
string
|
|
12
|
-
}) {
|
|
13
|
-
return mockReact.createElement('span', null, string);
|
|
14
|
-
}
|
|
15
|
-
Text.propTypes = {
|
|
16
|
-
params: () => null
|
|
17
|
-
};
|
|
18
|
-
Text.defaultProps = {
|
|
19
|
-
params: {}
|
|
20
|
-
};
|
|
21
|
-
const I18n = {
|
|
22
|
-
Text
|
|
23
|
-
};
|
|
24
|
-
function Ellipsis({
|
|
25
|
-
children
|
|
26
|
-
}) {
|
|
27
|
-
return mockReact.createElement('span', null, children);
|
|
28
|
-
}
|
|
29
|
-
function Button({
|
|
30
|
-
children,
|
|
31
|
-
onClick,
|
|
32
|
-
disabled,
|
|
33
|
-
className
|
|
34
|
-
}) {
|
|
35
|
-
return mockReact.createElement('button', {
|
|
36
|
-
onClick,
|
|
37
|
-
disabled,
|
|
38
|
-
className
|
|
39
|
-
}, children);
|
|
40
|
-
}
|
|
41
|
-
function Typography({
|
|
42
|
-
children
|
|
43
|
-
}) {
|
|
44
|
-
return mockReact.createElement('span', null, children);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
I18n,
|
|
48
|
-
Ellipsis,
|
|
49
|
-
Button,
|
|
50
|
-
Typography
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
describe('<HtmlContentDialog />', () => {
|
|
54
|
-
it('should render with minimal props', () => {
|
|
55
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
56
|
-
message: message,
|
|
57
|
-
actions: []
|
|
58
|
-
}));
|
|
59
|
-
expect(wrapper).toMatchSnapshot();
|
|
60
|
-
expect(wrapper.html()).toMatch(message);
|
|
61
|
-
});
|
|
62
|
-
it('should render with title and html message', () => {
|
|
63
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
64
|
-
title: title,
|
|
65
|
-
message: message,
|
|
66
|
-
actions: []
|
|
67
|
-
}));
|
|
68
|
-
expect(wrapper).toMatchSnapshot();
|
|
69
|
-
expect(wrapper.html()).toMatch(title);
|
|
70
|
-
});
|
|
71
|
-
it('should render with title, html message and messageParams', () => {
|
|
72
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
73
|
-
title: title,
|
|
74
|
-
message: "Message with {name}",
|
|
75
|
-
params: {
|
|
76
|
-
name: 'Placeholder'
|
|
77
|
-
},
|
|
78
|
-
actions: []
|
|
79
|
-
}));
|
|
80
|
-
expect(wrapper).toMatchSnapshot();
|
|
81
|
-
});
|
|
82
|
-
it('should render the actions', () => {
|
|
83
|
-
const actions = [{
|
|
84
|
-
label: 'fooAction',
|
|
85
|
-
action: () => {}
|
|
86
|
-
}];
|
|
87
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
88
|
-
title: title,
|
|
89
|
-
message: message,
|
|
90
|
-
actions: actions
|
|
91
|
-
}));
|
|
92
|
-
expect(wrapper).toMatchSnapshot();
|
|
93
|
-
expect(wrapper.html()).toMatch(actions[0].label);
|
|
94
|
-
});
|
|
95
|
-
it('should pass title through', () => {
|
|
96
|
-
const customTitle = /*#__PURE__*/_jsx("div", {
|
|
97
|
-
children: "Title"
|
|
98
|
-
});
|
|
99
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
100
|
-
title: customTitle,
|
|
101
|
-
message: message,
|
|
102
|
-
params: {},
|
|
103
|
-
actions: []
|
|
104
|
-
}));
|
|
105
|
-
expect(wrapper.find('BasicDialog').prop('title')).toEqual(customTitle);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount } from 'enzyme';
|
|
3
|
-
import PipelineErrorDialog from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
jest.mock('@shopgate/engage/a11y/components');
|
|
6
|
-
describe('<PipelineErrorDialog />', () => {
|
|
7
|
-
const defaultParams = {
|
|
8
|
-
code: '123',
|
|
9
|
-
message: 'Error message',
|
|
10
|
-
pipeline: 'fakePipeline',
|
|
11
|
-
request: {}
|
|
12
|
-
};
|
|
13
|
-
it('should render with minimal props', () => {
|
|
14
|
-
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
15
|
-
actions: [],
|
|
16
|
-
params: defaultParams
|
|
17
|
-
}));
|
|
18
|
-
expect(wrapper).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
it('should show a custom message if a message is is provided', () => {
|
|
21
|
-
const message = 'Custom message';
|
|
22
|
-
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
23
|
-
actions: [],
|
|
24
|
-
message: message,
|
|
25
|
-
params: defaultParams
|
|
26
|
-
}));
|
|
27
|
-
expect(wrapper).toMatchSnapshot();
|
|
28
|
-
expect(wrapper.html()).toMatch(message);
|
|
29
|
-
});
|
|
30
|
-
it('should switch modes on tap', () => {
|
|
31
|
-
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
32
|
-
actions: [],
|
|
33
|
-
params: defaultParams
|
|
34
|
-
}));
|
|
35
|
-
const numTaps = 10;
|
|
36
|
-
const clickElement = wrapper.find('div[onClick]');
|
|
37
|
-
const devMarker = 'Pipeline:';
|
|
38
|
-
|
|
39
|
-
// Dev mode should be disabled.
|
|
40
|
-
for (let i = 0; i < numTaps; i += 1) {
|
|
41
|
-
expect(wrapper.text()).not.toContain(devMarker);
|
|
42
|
-
clickElement.simulate('click');
|
|
43
|
-
}
|
|
44
|
-
expect(wrapper.text()).toContain(devMarker);
|
|
45
|
-
|
|
46
|
-
// Dev mode should be enabled until 10 more taps.
|
|
47
|
-
for (let i = 0; i < numTaps - 1; i += 1) {
|
|
48
|
-
expect(wrapper.text()).toContain(devMarker);
|
|
49
|
-
clickElement.simulate('click');
|
|
50
|
-
}
|
|
51
|
-
clickElement.simulate('click');
|
|
52
|
-
expect(wrapper.text()).not.toContain(devMarker);
|
|
53
|
-
});
|
|
54
|
-
it('should not switch modes if tapped too slow', () => {
|
|
55
|
-
jest.useFakeTimers();
|
|
56
|
-
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
57
|
-
actions: [],
|
|
58
|
-
params: defaultParams
|
|
59
|
-
}));
|
|
60
|
-
const numTaps = 10;
|
|
61
|
-
const numTapsUntilTimeout = Math.round(numTaps / 2);
|
|
62
|
-
const clickElement = wrapper.find('div[onClick]');
|
|
63
|
-
const devMarker = 'Pipeline:';
|
|
64
|
-
expect(wrapper.text()).not.toContain(devMarker);
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Simulates multiple tap events.
|
|
68
|
-
* @param {number} amount The number of tap events to simulate in a row.
|
|
69
|
-
*/
|
|
70
|
-
const tapOnElement = amount => {
|
|
71
|
-
if (amount > 0) {
|
|
72
|
-
clickElement.simulate('click');
|
|
73
|
-
tapOnElement(amount - 1);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// Tap a few times.
|
|
78
|
-
tapOnElement(numTapsUntilTimeout);
|
|
79
|
-
|
|
80
|
-
// Trigger a timeout (user was too slow).
|
|
81
|
-
jest.runAllTimers();
|
|
82
|
-
|
|
83
|
-
// Tap the remaining times.
|
|
84
|
-
tapOnElement(numTaps - numTapsUntilTimeout);
|
|
85
|
-
expect(wrapper.text()).not.toContain(devMarker);
|
|
86
|
-
tapOnElement(numTapsUntilTimeout);
|
|
87
|
-
expect(wrapper.text()).toContain(devMarker);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import TextMessageDialog from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const message = 'This is the message.';
|
|
6
|
-
const title = 'This is the title.';
|
|
7
|
-
jest.mock('@shopgate/engage/a11y/components');
|
|
8
|
-
describe('<TextMessageDialog />', () => {
|
|
9
|
-
it('should render with minimal props', () => {
|
|
10
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
11
|
-
message: message,
|
|
12
|
-
actions: []
|
|
13
|
-
}));
|
|
14
|
-
expect(wrapper).toMatchSnapshot();
|
|
15
|
-
expect(wrapper.html()).toMatch(message);
|
|
16
|
-
});
|
|
17
|
-
it('should render with title and message', () => {
|
|
18
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
19
|
-
title: title,
|
|
20
|
-
message: message,
|
|
21
|
-
actions: []
|
|
22
|
-
}));
|
|
23
|
-
expect(wrapper).toMatchSnapshot();
|
|
24
|
-
expect(wrapper.html()).toMatch(title);
|
|
25
|
-
});
|
|
26
|
-
it('should render with title, message and messageParams', () => {
|
|
27
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
28
|
-
title: title,
|
|
29
|
-
message: "Message with {name}",
|
|
30
|
-
params: {
|
|
31
|
-
name: 'Placeholder'
|
|
32
|
-
},
|
|
33
|
-
actions: []
|
|
34
|
-
}));
|
|
35
|
-
expect(wrapper).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
it('should render the actions', () => {
|
|
38
|
-
const actions = [{
|
|
39
|
-
label: 'fooAction',
|
|
40
|
-
action: () => {}
|
|
41
|
-
}];
|
|
42
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
43
|
-
title: title,
|
|
44
|
-
message: message,
|
|
45
|
-
actions: actions
|
|
46
|
-
}));
|
|
47
|
-
expect(wrapper).toMatchSnapshot();
|
|
48
|
-
expect(wrapper.html()).toMatch(actions[0].label);
|
|
49
|
-
});
|
|
50
|
-
it('should pass title through', () => {
|
|
51
|
-
const customTitle = /*#__PURE__*/_jsx("div", {
|
|
52
|
-
children: "Title"
|
|
53
|
-
});
|
|
54
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
55
|
-
title: customTitle,
|
|
56
|
-
message: message,
|
|
57
|
-
params: {},
|
|
58
|
-
actions: []
|
|
59
|
-
}));
|
|
60
|
-
expect(wrapper.find('BasicDialog').prop('title')).toEqual(customTitle);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { UnwrappedVariantSelectModal as VariantSelectModal } from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const message = 'This is the message.';
|
|
6
|
-
const title = 'This is the title.';
|
|
7
|
-
jest.mock('@shopgate/engage/a11y/components');
|
|
8
|
-
describe('<VariantSelectModal />', () => {
|
|
9
|
-
it('should render with minimal props', () => {
|
|
10
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(VariantSelectModal, {
|
|
11
|
-
message: message,
|
|
12
|
-
actions: [],
|
|
13
|
-
navigate: () => {}
|
|
14
|
-
}));
|
|
15
|
-
expect(wrapper).toMatchSnapshot();
|
|
16
|
-
expect(wrapper.html()).toMatch(message);
|
|
17
|
-
});
|
|
18
|
-
it('should render the actions', () => {
|
|
19
|
-
const mockConfirm = jest.fn();
|
|
20
|
-
const mockNavigate = jest.fn();
|
|
21
|
-
/**
|
|
22
|
-
* Mocks named function
|
|
23
|
-
*/
|
|
24
|
-
const onConfirm = () => {
|
|
25
|
-
mockConfirm();
|
|
26
|
-
};
|
|
27
|
-
const actions = [{
|
|
28
|
-
label: 'confirm',
|
|
29
|
-
action: onConfirm
|
|
30
|
-
}, {
|
|
31
|
-
label: 'dismiss',
|
|
32
|
-
action: () => {}
|
|
33
|
-
}];
|
|
34
|
-
const params = {
|
|
35
|
-
productId: 'product_1'
|
|
36
|
-
};
|
|
37
|
-
const mockedProps = {
|
|
38
|
-
message,
|
|
39
|
-
title,
|
|
40
|
-
params,
|
|
41
|
-
actions: [].concat(actions),
|
|
42
|
-
navigate: mockNavigate
|
|
43
|
-
};
|
|
44
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(VariantSelectModal, {
|
|
45
|
-
...mockedProps
|
|
46
|
-
}));
|
|
47
|
-
expect(wrapper).toMatchSnapshot();
|
|
48
|
-
const reordered = wrapper.find('BasicDialog').props().actions;
|
|
49
|
-
const last = reordered.slice(-1)[0];
|
|
50
|
-
expect(last.label).toEqual(actions[0].label);
|
|
51
|
-
last.action();
|
|
52
|
-
expect(mockConfirm).toHaveBeenCalledTimes(1);
|
|
53
|
-
expect(mockNavigate).toHaveBeenCalledTimes(1);
|
|
54
|
-
});
|
|
55
|
-
});
|
package/Dialog/spec.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow, ReactWrapper } from 'enzyme';
|
|
3
|
-
import { MODAL_PIPELINE_ERROR } from '@shopgate/pwa-common/constants/ModalTypes';
|
|
4
|
-
import { MODAL_VARIANT_SELECT } from "./constants";
|
|
5
|
-
import Dialog from "./index";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
jest.mock("./components/VariantSelectModal", () => {
|
|
8
|
-
/**
|
|
9
|
-
* VariantSelectModal mock.
|
|
10
|
-
* @return {JSX}
|
|
11
|
-
*/
|
|
12
|
-
const VariantSelectModal = () => /*#__PURE__*/_jsx("div", {});
|
|
13
|
-
return VariantSelectModal;
|
|
14
|
-
});
|
|
15
|
-
jest.mock('@shopgate/engage/components');
|
|
16
|
-
describe('<Dialog />', () => {
|
|
17
|
-
it('should render without props', () => {
|
|
18
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
19
|
-
modal: {
|
|
20
|
-
message: 'msg'
|
|
21
|
-
}
|
|
22
|
-
}));
|
|
23
|
-
expect(wrapper).toMatchSnapshot();
|
|
24
|
-
expect(wrapper.find('TextMessageDialog').length).toBe(1);
|
|
25
|
-
});
|
|
26
|
-
it('should render BasicDialog when no message given', () => {
|
|
27
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
28
|
-
modal: {
|
|
29
|
-
message: null
|
|
30
|
-
}
|
|
31
|
-
}));
|
|
32
|
-
expect(wrapper).toMatchSnapshot();
|
|
33
|
-
expect(wrapper.find('BasicDialog').length).toBe(1);
|
|
34
|
-
});
|
|
35
|
-
it('should render a special dialog', () => {
|
|
36
|
-
const params = {
|
|
37
|
-
errorCode: '',
|
|
38
|
-
message: '',
|
|
39
|
-
pipeline: '',
|
|
40
|
-
request: {}
|
|
41
|
-
};
|
|
42
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
43
|
-
modal: {
|
|
44
|
-
type: MODAL_PIPELINE_ERROR,
|
|
45
|
-
params
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
expect(wrapper).toMatchSnapshot();
|
|
49
|
-
expect(wrapper.find('DefaultDialog').length).toBe(0);
|
|
50
|
-
expect(wrapper.find('PipelineErrorDialog').length).toBe(1);
|
|
51
|
-
});
|
|
52
|
-
it('should render variant select dialog', () => {
|
|
53
|
-
const params = {
|
|
54
|
-
productId: 'product_1'
|
|
55
|
-
};
|
|
56
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
57
|
-
modal: {
|
|
58
|
-
message: 'Test',
|
|
59
|
-
type: MODAL_VARIANT_SELECT,
|
|
60
|
-
params
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
expect(wrapper).toMatchSnapshot();
|
|
64
|
-
expect(wrapper.find('DefaultDialog').length).toBe(0);
|
|
65
|
-
expect(wrapper.find('VariantSelectModal').length).toBe(1);
|
|
66
|
-
});
|
|
67
|
-
it('should convert title into translatable element', () => {
|
|
68
|
-
const title = 'translate.me';
|
|
69
|
-
const titleParams = {
|
|
70
|
-
foo: 'bar'
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// eslint-disable-next-line extra-rules/no-single-line-objects
|
|
74
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
75
|
-
modal: {
|
|
76
|
-
title,
|
|
77
|
-
titleParams
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
const i18n = new ReactWrapper(wrapper.find('BasicDialog').prop('title'));
|
|
81
|
-
expect(i18n.prop('string')).toEqual(title);
|
|
82
|
-
expect(i18n.prop('params')).toEqual(titleParams);
|
|
83
|
-
});
|
|
84
|
-
});
|
package/DiscountBadge/spec.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import DiscountBadge from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
jest.mock('@shopgate/engage/components');
|
|
6
|
-
describe('<DiscountBadge />', () => {
|
|
7
|
-
it('should render the text', () => {
|
|
8
|
-
const wrapper = render(/*#__PURE__*/_jsx(DiscountBadge, {
|
|
9
|
-
text: "foo"
|
|
10
|
-
}));
|
|
11
|
-
expect(wrapper.asFragment()).toMatchSnapshot();
|
|
12
|
-
});
|
|
13
|
-
it('should render the text and discount', () => {
|
|
14
|
-
const wrapper = render(/*#__PURE__*/_jsx(DiscountBadge, {
|
|
15
|
-
text: "SAVE {0}%",
|
|
16
|
-
discount: 20
|
|
17
|
-
}));
|
|
18
|
-
expect(wrapper.asFragment()).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
});
|
package/FavoritesButton/spec.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act } from 'react-dom/test-utils';
|
|
3
|
-
import { Provider } from 'react-redux';
|
|
4
|
-
import configureStore from 'redux-mock-store';
|
|
5
|
-
import { mount } from 'enzyme';
|
|
6
|
-
import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
|
|
7
|
-
import appConfig from '@shopgate/pwa-common/helpers/config';
|
|
8
|
-
import FavoritesButton from "./index";
|
|
9
|
-
import { mockedStateEmpty, mockedStateOnList, mockedStateNotOnList } from "./mock";
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const mockedStore = configureStore();
|
|
12
|
-
const dispatcher = jest.fn();
|
|
13
|
-
jest.mock('@shopgate/pwa-common/helpers/config');
|
|
14
|
-
jest.mock('@shopgate/pwa-common-commerce/favorites/selectors/index', () => ({
|
|
15
|
-
isFetching: () => false
|
|
16
|
-
}));
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
jest.resetModules();
|
|
19
|
-
});
|
|
20
|
-
describe('<FavoritesButton />', () => {
|
|
21
|
-
let component = null;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Creates component with provided store state.
|
|
25
|
-
* @param {Object} mockedState Mocked stage.
|
|
26
|
-
* @param {Object} props Additional props.
|
|
27
|
-
* @return {ReactWrapper}
|
|
28
|
-
*/
|
|
29
|
-
const createComponent = (mockedState, props = {
|
|
30
|
-
active: false
|
|
31
|
-
}) => {
|
|
32
|
-
const store = mockedStore(mockedState);
|
|
33
|
-
store.dispatch = dispatcher;
|
|
34
|
-
return mount(/*#__PURE__*/_jsx(Provider, {
|
|
35
|
-
store: store,
|
|
36
|
-
children: /*#__PURE__*/_jsx(FavoritesButton, {
|
|
37
|
-
...props
|
|
38
|
-
})
|
|
39
|
-
}), mockRenderOptions);
|
|
40
|
-
};
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
dispatcher.mockReset();
|
|
43
|
-
});
|
|
44
|
-
it('should only render when no favorites set', () => {
|
|
45
|
-
component = createComponent(mockedStateEmpty);
|
|
46
|
-
expect(component).toMatchSnapshot();
|
|
47
|
-
expect(component.find('Heart').exists()).toBe(false);
|
|
48
|
-
expect(component.find('HeartOutline').exists()).toBe(true);
|
|
49
|
-
component.find('button').simulate('click');
|
|
50
|
-
});
|
|
51
|
-
it('should render when favorites set', () => {
|
|
52
|
-
component = createComponent(mockedStateOnList, {
|
|
53
|
-
active: true
|
|
54
|
-
});
|
|
55
|
-
expect(component).toMatchSnapshot();
|
|
56
|
-
expect(component.find('Heart').exists()).toBe(true);
|
|
57
|
-
expect(component.find('HeartOutline').exists()).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
it('should add to favorites on click', () => {
|
|
60
|
-
component = createComponent(mockedStateNotOnList, {
|
|
61
|
-
productId: '1',
|
|
62
|
-
active: false
|
|
63
|
-
});
|
|
64
|
-
expect(component.find('Heart').exists()).toBe(false);
|
|
65
|
-
expect(component.find('HeartOutline').exists()).toBe(true);
|
|
66
|
-
component.find('button').simulate('click');
|
|
67
|
-
component.update();
|
|
68
|
-
expect(dispatcher).toHaveBeenCalled();
|
|
69
|
-
});
|
|
70
|
-
it('should remove from favorites on click', done => {
|
|
71
|
-
component = createComponent(mockedStateOnList, {
|
|
72
|
-
productId: '1',
|
|
73
|
-
active: true
|
|
74
|
-
});
|
|
75
|
-
expect(component.find('Heart').exists()).toBe(true);
|
|
76
|
-
expect(component.find('HeartOutline').exists()).toBe(false);
|
|
77
|
-
component.find('button').simulate('click');
|
|
78
|
-
component.update();
|
|
79
|
-
setTimeout(() => {
|
|
80
|
-
expect(dispatcher).toHaveBeenCalled();
|
|
81
|
-
done();
|
|
82
|
-
}, 0);
|
|
83
|
-
});
|
|
84
|
-
it('should process ripple complete callback', async () => {
|
|
85
|
-
const onRippleComplete = jest.fn();
|
|
86
|
-
component = createComponent(mockedStateOnList, {
|
|
87
|
-
productId: '1',
|
|
88
|
-
active: true,
|
|
89
|
-
onRippleComplete
|
|
90
|
-
});
|
|
91
|
-
await act(async () => {
|
|
92
|
-
component.find('Ripple').invoke('onComplete')();
|
|
93
|
-
});
|
|
94
|
-
component.update();
|
|
95
|
-
expect(onRippleComplete).toHaveBeenCalled();
|
|
96
|
-
});
|
|
97
|
-
it('should only react on first click', done => {
|
|
98
|
-
component = createComponent(mockedStateOnList, {
|
|
99
|
-
once: true,
|
|
100
|
-
productId: '1',
|
|
101
|
-
active: false
|
|
102
|
-
});
|
|
103
|
-
component.find('button').simulate('click');
|
|
104
|
-
component.update();
|
|
105
|
-
component.find('button').simulate('click');
|
|
106
|
-
component.update();
|
|
107
|
-
setTimeout(() => {
|
|
108
|
-
expect(dispatcher.mock.calls.length).toBe(1);
|
|
109
|
-
done();
|
|
110
|
-
}, 1);
|
|
111
|
-
});
|
|
112
|
-
it('should only react on both clicks', done => {
|
|
113
|
-
component = createComponent(mockedStateOnList, {
|
|
114
|
-
productId: '1',
|
|
115
|
-
active: false
|
|
116
|
-
});
|
|
117
|
-
component.find('button').simulate('click');
|
|
118
|
-
component.update();
|
|
119
|
-
component.find('button').simulate('click');
|
|
120
|
-
component.update();
|
|
121
|
-
setTimeout(() => {
|
|
122
|
-
expect(dispatcher.mock.calls.length).toBe(2);
|
|
123
|
-
done();
|
|
124
|
-
}, 1);
|
|
125
|
-
});
|
|
126
|
-
it('should render null when feature flag is off', () => {
|
|
127
|
-
jest.spyOn(appConfig, 'hasFavorites', 'get').mockReturnValue(false);
|
|
128
|
-
component = createComponent(mockedStateOnList);
|
|
129
|
-
expect(component.isEmptyRender()).toBe(true);
|
|
130
|
-
});
|
|
131
|
-
});
|