@shopgate/pwa-ui-shared 7.32.0-beta.2 → 7.32.0-beta.21

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 (68) hide show
  1. package/ActionButton/index.js +4 -0
  2. package/AddToCartButton/index.js +4 -1
  3. package/Button/index.js +10 -3
  4. package/ButtonLink/index.js +4 -0
  5. package/Card/index.js +13 -34
  6. package/CardList/components/Item/index.js +26 -20
  7. package/CardList/index.js +2 -1
  8. package/CartTotalLine/index.js +1 -1
  9. package/Dialog/components/PipelineErrorDialog/index.js +2 -1
  10. package/DiscountBadge/index.js +1 -1
  11. package/FavoritesButton/FavoritesButton.d.ts +74 -0
  12. package/FavoritesButton/FavoritesButton.d.ts.map +1 -0
  13. package/FavoritesButton/FavoritesButton.js +87 -0
  14. package/FavoritesButton/connector.d.ts +3 -0
  15. package/FavoritesButton/connector.d.ts.map +1 -0
  16. package/FavoritesButton/index.d.ts +3 -0
  17. package/FavoritesButton/index.d.ts.map +1 -0
  18. package/FavoritesButton/index.js +1 -134
  19. package/Glow/index.js +4 -3
  20. package/NoResults/components/Icon/index.js +4 -1
  21. package/NoResults/index.js +1 -1
  22. package/Price/index.js +11 -4
  23. package/PriceStriked/index.js +7 -1
  24. package/RatingStars/index.js +16 -5
  25. package/RippleButton/index.js +5 -1
  26. package/Sheet/index.js +11 -1
  27. package/TaxDisclaimer/index.js +0 -1
  28. package/package.json +5 -5
  29. package/AccordionContainer/spec.js +0 -35
  30. package/ActionButton/spec.js +0 -66
  31. package/AddToCartButton/spec.js +0 -68
  32. package/Availability/spec.js +0 -42
  33. package/Button/spec.js +0 -38
  34. package/ButtonLink/spec.js +0 -29
  35. package/Chip/spec.js +0 -27
  36. package/ContextMenu/spec.js +0 -113
  37. package/Dialog/components/HtmlContentDialog/spec.js +0 -107
  38. package/Dialog/components/PipelineErrorDialog/spec.js +0 -89
  39. package/Dialog/components/TextMessageDialog/spec.js +0 -62
  40. package/Dialog/components/VariantSelectModal/spec.js +0 -55
  41. package/Dialog/spec.js +0 -84
  42. package/DiscountBadge/spec.js +0 -20
  43. package/FavoritesButton/spec.js +0 -131
  44. package/Form/Builder/classes/ActionListener/spec.js +0 -323
  45. package/Form/Builder/spec.js +0 -309
  46. package/Form/InfoField/spec.js +0 -12
  47. package/Form/Password/spec.js +0 -39
  48. package/Form/RadioGroup/spec.js +0 -97
  49. package/Form/Select/spec.js +0 -39
  50. package/Form/SelectContextChoices/spec.js +0 -36
  51. package/Form/TextField/spec.js +0 -124
  52. package/FormElement/spec.js +0 -68
  53. package/Glow/spec.js +0 -14
  54. package/IndicatorCircle/spec.js +0 -26
  55. package/PlaceholderLabel/spec.js +0 -26
  56. package/PlaceholderParagraph/spec.js +0 -26
  57. package/ProgressBar/spec.js +0 -14
  58. package/RadioButton/spec.js +0 -22
  59. package/RatingStars/spec.js +0 -91
  60. package/RippleButton/spec.js +0 -58
  61. package/Sheet/components/Header/components/SearchBar/spec.js +0 -22
  62. package/Sheet/components/Header/spec.js +0 -17
  63. package/Sheet/spec.js +0 -100
  64. package/TaxDisclaimer/spec.js +0 -44
  65. package/TextField/spec.js +0 -146
  66. package/ToggleIcon/spec.js +0 -39
  67. package/tsconfig.build.json +0 -16
  68. package/tsconfig.json +0 -3
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
4
- import Header from "./index";
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- describe('<Header />', () => {
7
- it('should render with correct title', () => {
8
- const title = 'My Title';
9
- const wrapper = shallow(/*#__PURE__*/_jsx(Header, {
10
- title: title
11
- }), mockRenderOptions);
12
- expect(wrapper).toMatchSnapshot();
13
- expect(wrapper.find({
14
- variant: 'h3'
15
- }).first().props().children).toEqual(title);
16
- });
17
- });
package/Sheet/spec.js DELETED
@@ -1,100 +0,0 @@
1
- import React from 'react';
2
- import { shallow, mount } from 'enzyme';
3
- import Drawer from '@shopgate/pwa-common/components/Drawer';
4
- import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
5
- import UIEvents from '@shopgate/pwa-core/emitters/ui';
6
- import Sheet, { SHEET_EVENTS } from "./index";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- window.requestAnimationFrame = () => {};
9
- jest.mock('@shopgate/pwa-core/emitters/ui', () => ({
10
- emit: jest.fn()
11
- }));
12
- jest.mock('@shopgate/engage/a11y/components');
13
- describe('<Sheet />', () => {
14
- it('should render closed without content', () => {
15
- const wrapper = shallow(/*#__PURE__*/_jsx(Sheet, {}));
16
- expect(wrapper).toMatchSnapshot();
17
- });
18
- it('should render opened without content', () => {
19
- const wrapper = shallow(/*#__PURE__*/_jsx(Sheet, {
20
- isOpen: true
21
- }));
22
- expect(wrapper).toMatchSnapshot();
23
- });
24
- it('should render with content and title', () => {
25
- const wrapper = shallow(/*#__PURE__*/_jsx(Sheet, {
26
- isOpen: true,
27
- title: "Test-Title",
28
- children: /*#__PURE__*/_jsx("div", {
29
- children: "Test"
30
- })
31
- }));
32
- expect(wrapper).toMatchSnapshot();
33
- });
34
- it('should call onDidOpen callback when the Sheet was opened', () => {
35
- const onOpen = jest.fn();
36
- const onDidOpen = jest.fn();
37
- const wrapper = mount(/*#__PURE__*/_jsx(Sheet, {
38
- isOpen: false,
39
- onOpen: onOpen,
40
- onDidOpen: onDidOpen,
41
- children: /*#__PURE__*/_jsx("div", {
42
- children: "Test"
43
- })
44
- }), mockRenderOptions);
45
- expect(onOpen).not.toHaveBeenCalled();
46
- expect(onDidOpen).not.toHaveBeenCalled();
47
- wrapper.setProps({
48
- isOpen: true
49
- });
50
- wrapper.update();
51
- expect(onOpen).toHaveBeenCalled();
52
- wrapper.find(Drawer).simulate('animationEnd');
53
- expect(onDidOpen).toHaveBeenCalled();
54
- expect(UIEvents.emit).nthCalledWith(1, SHEET_EVENTS.OPEN);
55
- });
56
- it('should trigger onClose callback and close the Sheet', () => {
57
- const onCloseSpy = jest.fn();
58
- const wrapper = mount(/*#__PURE__*/_jsx(Sheet, {
59
- isOpen: true,
60
- title: "Test-Title",
61
- onClose: onCloseSpy,
62
- children: /*#__PURE__*/_jsx("div", {
63
- children: "Test"
64
- })
65
- }), mockRenderOptions);
66
-
67
- // Trigger a click on the close button of the Sheet.
68
- wrapper.find('button').first().simulate('click');
69
- return new Promise(resolve => {
70
- // Wait until the drawer is closed and has updated it's state.
71
- setTimeout(() => {
72
- resolve();
73
- }, wrapper.find(Drawer).prop('animation').duration);
74
- }).then(() => {
75
- // Check if onClose callback was called.
76
- expect(onCloseSpy).toHaveBeenCalled();
77
-
78
- // Check if the Drawer component was closed.
79
- expect(wrapper.find(Drawer).prop('isOpen')).not.toBeTruthy();
80
- expect(wrapper).toMatchSnapshot();
81
- wrapper.find(Drawer).simulate('animationEnd');
82
- expect(UIEvents.emit).lastCalledWith(SHEET_EVENTS.CLOSE);
83
- });
84
- });
85
- it('should open', () => {
86
- const wrapper = mount(/*#__PURE__*/_jsx(Sheet, {
87
- isOpen: false,
88
- title: "Test-Title",
89
- children: /*#__PURE__*/_jsx("div", {
90
- children: "Test"
91
- })
92
- }), mockRenderOptions);
93
- wrapper.setProps({
94
- isOpen: true
95
- });
96
- wrapper.update();
97
- expect(wrapper.find(Drawer).prop('isOpen')).toBeTruthy();
98
- expect(wrapper).toMatchSnapshot();
99
- });
100
- });
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import { I18n } from '@shopgate/engage/components';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- jest.mock('@shopgate/engage/components');
6
- jest.mock('@shopgate/engage/styles', () => ({
7
- makeStyles: () => function mockUseStylesFactory() {
8
- return function useStylesMock() {
9
- return {
10
- classes: {
11
- text: 'mock-class-text'
12
- },
13
- cx: (...classes) => classes.filter(Boolean).join(' ')
14
- };
15
- };
16
- },
17
- keyframes: () => ({})
18
- }));
19
- jest.mock('@shopgate/engage/core/hooks/useWidgetSettings', () => ({
20
- useWidgetSettings: jest.fn().mockReturnValue({
21
- show: null,
22
- hint: '*',
23
- text: null
24
- })
25
- }));
26
- describe('<TaxDisclaimer />', () => {
27
- afterEach(() => {
28
- jest.resetModules();
29
- });
30
- it('should display the component', () => {
31
- jest.mock('@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer', () => true);
32
- const TaxDisclaimer = jest.requireActual("./index").default;
33
- const wrapper = shallow(/*#__PURE__*/_jsx(TaxDisclaimer, {}));
34
- expect(wrapper).toMatchSnapshot();
35
- expect(wrapper.find(I18n.Text).exists()).toBe(true);
36
- });
37
- it('should display null', () => {
38
- jest.mock('@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer', () => false);
39
- const TaxDisclaimer = jest.requireActual("./index").default;
40
- const wrapper = shallow(/*#__PURE__*/_jsx(TaxDisclaimer, {}));
41
- expect(wrapper).toMatchSnapshot();
42
- expect(wrapper.find(I18n.Text).exists()).toBe(false);
43
- });
44
- });
package/TextField/spec.js DELETED
@@ -1,146 +0,0 @@
1
- import React from 'react';
2
- import { mount } from 'enzyme';
3
- import TextField from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const inputProps = {
6
- name: 'test-input'
7
- };
8
- describe('<TextField />', () => {
9
- it('should render a simple text field', () => {
10
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
11
- ...inputProps
12
- }));
13
- expect(wrapper).toMatchSnapshot();
14
- expect(wrapper.find('input').length).toBe(1);
15
- });
16
- it('should render the text field as password', () => {
17
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
18
- ...inputProps,
19
- password: true
20
- }));
21
- expect(wrapper).toMatchSnapshot();
22
- expect(wrapper.find('input[type="password"]').length).toBe(1);
23
- });
24
- it('should render the text field with a default value', () => {
25
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
26
- ...inputProps,
27
- value: "FooBar"
28
- }));
29
- expect(wrapper).toMatchSnapshot();
30
- expect(wrapper.find('input[value="FooBar"]').length).toBe(1);
31
- });
32
- it('should trigger the onChange callback', () => {
33
- const onChangeMock = jest.fn();
34
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
35
- ...inputProps,
36
- onChange: onChangeMock
37
- }));
38
- wrapper.find('input').simulate('change', {
39
- target: {
40
- value: 'a'
41
- }
42
- });
43
- expect(onChangeMock).toHaveBeenCalledTimes(2);
44
- expect(wrapper.find('input').props().value).toEqual('a');
45
- });
46
- it('should receive the correct value while typing', () => {
47
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
48
- ...inputProps
49
- }));
50
- const input = wrapper.find('input');
51
- input.simulate('change', {
52
- target: {
53
- value: 'foobar'
54
- }
55
- });
56
- expect(wrapper).toMatchSnapshot();
57
- expect(input.instance().value).toBe('foobar');
58
- });
59
- it('should sanitize the input', () => {
60
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
61
- ...inputProps,
62
- onSanitize: value => value.toUpperCase()
63
- }));
64
- const input = wrapper.find('input');
65
- input.simulate('change', {
66
- target: {
67
- value: 'foobar'
68
- }
69
- });
70
- expect(wrapper).toMatchSnapshot();
71
- expect(input.instance().value).toBe('FOOBAR');
72
- });
73
- it('should trigger the validation callback', () => {
74
- const onValidateMock = jest.fn();
75
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
76
- ...inputProps,
77
- onValidate: onValidateMock
78
- }));
79
- expect(wrapper).toMatchSnapshot();
80
- expect(onValidateMock).toHaveBeenCalled();
81
- });
82
- it('should focus the input', () => {
83
- const onFocusMock = jest.fn();
84
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
85
- ...inputProps,
86
- onFocusChange: onFocusMock
87
- }));
88
- const input = wrapper.find('input');
89
- expect(wrapper).toMatchSnapshot();
90
- expect(onFocusMock).toHaveBeenCalledTimes(0);
91
- input.simulate('focus');
92
- expect(onFocusMock).toHaveBeenCalledTimes(1);
93
- expect(onFocusMock).toHaveBeenCalledWith(true);
94
- input.simulate('blur');
95
- expect(onFocusMock).toHaveBeenCalledTimes(2);
96
- expect(onFocusMock).toHaveBeenCalledWith(false);
97
- });
98
- it('should show the error message', () => {
99
- const errorText = 'This is an error here';
100
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
101
- ...inputProps,
102
- errorText: errorText
103
- }));
104
- expect(wrapper).toMatchSnapshot();
105
- expect(wrapper.find('Translate').at(2).props().string).toEqual(errorText);
106
- });
107
- it('should show the label', () => {
108
- const label = 'This is the label';
109
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
110
- ...inputProps,
111
- label: label
112
- }));
113
- expect(wrapper).toMatchSnapshot();
114
- expect(wrapper.find('Label').find('Translate').props().string).toEqual(label);
115
- });
116
- it('should show the hint text', () => {
117
- const hintText = 'This is the hint text';
118
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
119
- ...inputProps,
120
- hintText: hintText
121
- }));
122
- expect(wrapper).toMatchSnapshot();
123
- expect(wrapper.find('Hint').find('Translate').at(0).props().string).toEqual(hintText);
124
- });
125
- it('should replace the error text with custom validation error', () => {
126
- /**
127
- * A custom validation method that always returns an error.
128
- * @return {string} The error message.
129
- */
130
- const onValidate = () => 'Custom validation error';
131
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
132
- ...inputProps,
133
- onValidate: onValidate
134
- }));
135
- wrapper.find('input').simulate('blur');
136
- expect(wrapper).toMatchSnapshot();
137
- // Expect at least one element containing the validation error text.
138
- expect(wrapper.findWhere(node => {
139
- try {
140
- return node.text() === onValidate();
141
- } catch (e) {
142
- return false;
143
- }
144
- }).length).toBeGreaterThan(0);
145
- });
146
- });
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import { mount } from 'enzyme';
3
- import ToggleIcon from "./index";
4
- import VisibilityIcon from "../icons/VisibilityIcon";
5
- import VisibilityOffIcon from "../icons/VisibilityOffIcon";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- const inputProps = {
8
- onIcon: /*#__PURE__*/_jsx(VisibilityIcon, {}),
9
- offIcon: /*#__PURE__*/_jsx(VisibilityOffIcon, {})
10
- };
11
- describe('<ToggleIcon>', () => {
12
- it('should render a toggle icon', () => {
13
- const wrapper = mount(/*#__PURE__*/_jsx(ToggleIcon, {
14
- ...inputProps
15
- }));
16
- expect(wrapper).toMatchSnapshot();
17
- expect(wrapper.find('VisibilityIcon').length).toBe(1);
18
- expect(wrapper.find('VisibilityOffIcon').length).toBe(0);
19
- });
20
- it('should render a toggle icon with false as default', () => {
21
- const wrapper = mount(/*#__PURE__*/_jsx(ToggleIcon, {
22
- ...inputProps,
23
- on: false
24
- }));
25
- expect(wrapper).toMatchSnapshot();
26
- expect(wrapper.find('VisibilityIcon').length).toBe(0);
27
- expect(wrapper.find('VisibilityOffIcon').length).toBe(1);
28
- });
29
- it('should trigger the toggleHandler callback', () => {
30
- const mockToggleHandler = jest.fn();
31
- const wrapper = mount(/*#__PURE__*/_jsx(ToggleIcon, {
32
- ...inputProps,
33
- toggleHandler: mockToggleHandler
34
- }));
35
- wrapper.find('div').simulate('click');
36
- expect(wrapper).toMatchSnapshot();
37
- expect(mockToggleHandler.mock.calls.length).toBe(1);
38
- });
39
- });
@@ -1,16 +0,0 @@
1
- {
2
- "extends": "@shopgate/engage/tsconfig.build.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "."
6
- },
7
- "include": ["**/*.ts", "**/*.tsx"],
8
- "exclude": [
9
- "dist",
10
- "node_modules",
11
- "**/*.spec.*",
12
- "**/__tests__/**",
13
- "**/__snapshots__/**",
14
- "coverage"
15
- ]
16
- }
package/tsconfig.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@shopgate/engage/tsconfig.json",
3
- }