@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,97 +0,0 @@
1
- import React from 'react';
2
- import { mount } from 'enzyme';
3
- import RadioItem from "./components/Item";
4
- import RadioGroup from '.';
5
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
- const defProps = {
7
- name: 'radio'
8
- };
9
- jest.mock('@shopgate/engage/components');
10
- describe('<RadioGroup />', () => {
11
- it('should render empty group', () => {
12
- const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
13
- ...defProps
14
- }));
15
- expect(wrapper).toMatchSnapshot();
16
- });
17
- it('should render column group with items', () => {
18
- const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
19
- ...defProps,
20
- children: /*#__PURE__*/_jsx(RadioItem, {
21
- name: "foo",
22
- label: "foo"
23
- })
24
- }));
25
- expect(wrapper).toMatchSnapshot();
26
- expect(wrapper.find(RadioItem).length).toEqual(1);
27
- expect(typeof wrapper.find(RadioItem).prop('onChange')).toEqual('function');
28
- });
29
- it('should render rows group with items', () => {
30
- const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
31
- ...defProps,
32
- direction: "rows",
33
- children: /*#__PURE__*/_jsx(RadioItem, {
34
- name: "foo",
35
- label: "foo"
36
- })
37
- }));
38
- expect(wrapper).toMatchSnapshot();
39
- });
40
- it('should use default value', () => {
41
- const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
42
- ...defProps,
43
- value: "foo",
44
- children: /*#__PURE__*/_jsx(RadioItem, {
45
- name: "foo",
46
- label: "foo"
47
- })
48
- }));
49
- expect(wrapper).toMatchSnapshot();
50
- expect(wrapper.find(RadioItem).length).toEqual(1);
51
- expect(wrapper.find(RadioItem).prop('checked')).toEqual(true);
52
- });
53
- it('should have on value at a time', () => {
54
- const wrapper = mount(/*#__PURE__*/_jsxs(RadioGroup, {
55
- ...defProps,
56
- children: [/*#__PURE__*/_jsx(RadioItem, {
57
- name: "foo",
58
- label: "foo"
59
- }), /*#__PURE__*/_jsx(RadioItem, {
60
- name: "bar",
61
- label: "bar"
62
- })]
63
- }));
64
- expect(wrapper).toMatchSnapshot();
65
- expect(wrapper.find(RadioItem).length).toEqual(2);
66
- const radio1 = wrapper.find(RadioItem).at(0).find('input');
67
- const radio2 = wrapper.find(RadioItem).at(1).find('input');
68
-
69
- // First element value
70
- radio1.simulate('change');
71
- wrapper.update();
72
- expect(wrapper.find(RadioItem).at(0).prop('checked')).toEqual(true);
73
- expect(wrapper.find(RadioItem).at(1).prop('checked')).toEqual(false);
74
-
75
- // Second element value
76
- radio2.simulate('change');
77
- wrapper.update();
78
- expect(wrapper.find(RadioItem).at(0).prop('checked')).toEqual(false);
79
- expect(wrapper.find(RadioItem).at(1).prop('checked')).toEqual(true);
80
- });
81
- it('should call onChange callback', () => {
82
- const onChange = jest.fn();
83
- const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
84
- ...defProps,
85
- onChange: onChange,
86
- children: /*#__PURE__*/_jsx(RadioItem, {
87
- name: "foo",
88
- label: "foo"
89
- })
90
- }));
91
- expect(wrapper).toMatchSnapshot();
92
- expect(wrapper.find(RadioItem).length).toEqual(1);
93
- const radio = wrapper.find(RadioItem).at(0).find('input');
94
- radio.simulate('change');
95
- expect(onChange).toHaveBeenCalledWith('foo');
96
- });
97
- });
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import Select from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const inputProps = {
6
- name: 'test-name'
7
- };
8
- describe('<Select />', () => {
9
- // Simple tests for snapshots
10
- const tests = {
11
- 'should render select with no options': {},
12
- // eslint-disable-next-line extra-rules/no-single-line-objects
13
- 'should render select with 2 options': {
14
- options: {
15
- DE: 'Germany',
16
- US: 'United states'
17
- }
18
- },
19
- // eslint-disable-next-line extra-rules/no-single-line-objects
20
- 'should render select with 1 selected option': {
21
- options: {
22
- DE: 'Germany',
23
- US: 'United states'
24
- },
25
- value: 'DE'
26
- }
27
- };
28
- Object.keys(tests).forEach(test => {
29
- it(test, () => {
30
- const testFixtures = tests[test];
31
- // eslint-disable-next-line extra-rules/no-single-line-objects
32
- const wrapper = render(/*#__PURE__*/_jsx(Select, {
33
- ...inputProps,
34
- ...testFixtures
35
- }));
36
- expect(wrapper.asFragment()).toMatchSnapshot();
37
- });
38
- });
39
- });
@@ -1,36 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import SelectContextChoices from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- jest.mock('@shopgate/engage/a11y/components');
6
- jest.mock('@shopgate/engage/components');
7
- describe('<SelectContextChoices />', () => {
8
- // Simple tests for snapshots
9
- const tests = {
10
- 'should render select with no options': {},
11
- // eslint-disable-next-line extra-rules/no-single-line-objects
12
- 'should render select with 2 options': {
13
- options: {
14
- DE: 'Germany',
15
- US: 'United states'
16
- }
17
- },
18
- // eslint-disable-next-line extra-rules/no-single-line-objects
19
- 'should render select with 1 selected option': {
20
- options: {
21
- DE: 'Germany',
22
- US: 'United states'
23
- },
24
- value: ['DE']
25
- }
26
- };
27
- Object.keys(tests).forEach(test => {
28
- it(test, () => {
29
- const testFixtures = tests[test];
30
- const wrapper = render(/*#__PURE__*/_jsx(SelectContextChoices, {
31
- ...testFixtures
32
- }));
33
- expect(wrapper.asFragment()).toMatchSnapshot();
34
- });
35
- });
36
- });
@@ -1,124 +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
- jest.mock('@shopgate/engage/components');
9
- describe('<TextField>', () => {
10
- it('should render a simple text field', () => {
11
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
12
- ...inputProps
13
- }));
14
- expect(wrapper).toMatchSnapshot();
15
- expect(wrapper.find('input').length).toBe(1);
16
- });
17
- it('should render the text field as password', () => {
18
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
19
- ...inputProps,
20
- password: true
21
- }));
22
- expect(wrapper).toMatchSnapshot();
23
- expect(wrapper.find('input[type="password"]').length).toBe(1);
24
- });
25
- it('should render the text field with a default value', () => {
26
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
27
- ...inputProps,
28
- value: "FooBar"
29
- }));
30
- expect(wrapper).toMatchSnapshot();
31
- expect(wrapper.find('input[value="FooBar"]').length).toBe(1);
32
- });
33
- it('should trigger the onChange callback', () => {
34
- const onChangeMock = jest.fn();
35
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
36
- ...inputProps,
37
- onChange: onChangeMock
38
- }));
39
- wrapper.find('input').simulate('change', {
40
- target: {
41
- value: 'a'
42
- }
43
- });
44
- expect(onChangeMock).toHaveBeenCalledTimes(2);
45
- expect(wrapper.find('input').props().value).toEqual('a');
46
- });
47
- it('should receive the correct value while typing', () => {
48
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
49
- ...inputProps
50
- }));
51
- const input = wrapper.find('input');
52
- input.simulate('change', {
53
- target: {
54
- value: 'foobar'
55
- }
56
- });
57
- expect(wrapper).toMatchSnapshot();
58
- expect(input.instance().value).toBe('foobar');
59
- });
60
- it('should sanitize the input', () => {
61
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
62
- ...inputProps,
63
- onSanitize: value => value.toUpperCase()
64
- }));
65
- const input = wrapper.find('input');
66
- input.simulate('change', {
67
- target: {
68
- value: 'foobar'
69
- }
70
- });
71
- expect(wrapper).toMatchSnapshot();
72
- expect(input.instance().value).toBe('FOOBAR');
73
- });
74
- it('should trigger the validation callback', () => {
75
- const onValidateMock = jest.fn();
76
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
77
- ...inputProps,
78
- onValidate: onValidateMock
79
- }));
80
- expect(wrapper).toMatchSnapshot();
81
- expect(onValidateMock).toHaveBeenCalled();
82
- });
83
- it('should focus the input', () => {
84
- const onFocusMock = jest.fn();
85
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
86
- ...inputProps,
87
- onFocusChange: onFocusMock
88
- }));
89
- const input = wrapper.find('SimpleInput');
90
- expect(wrapper).toMatchSnapshot();
91
- expect(input.instance().isFocused).toBe(false);
92
- input.simulate('focus');
93
- expect(input.instance().isFocused).toBe(true);
94
- input.simulate('blur');
95
- expect(input.instance().isFocused).toBe(false);
96
- });
97
- it('should show the error message', () => {
98
- const errorText = 'This is an error here';
99
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
100
- ...inputProps,
101
- errorText: errorText
102
- }));
103
- expect(wrapper).toMatchSnapshot();
104
- expect(wrapper.find('ErrorText').find('Text').at(0).props().string).toEqual(errorText);
105
- });
106
- it('should show the label', () => {
107
- const label = 'This is the label';
108
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
109
- ...inputProps,
110
- label: label
111
- }));
112
- expect(wrapper).toMatchSnapshot();
113
- expect(wrapper.find('Label').find('Text').props().string).toEqual(label);
114
- });
115
- it('should show the placeholder text', () => {
116
- const placeholder = 'This is the placeholder text';
117
- const wrapper = mount(/*#__PURE__*/_jsx(TextField, {
118
- ...inputProps,
119
- placeholder: placeholder
120
- }));
121
- expect(wrapper).toMatchSnapshot();
122
- expect(wrapper.find('Placeholder').find('Text').at(0).props().string).toEqual(placeholder);
123
- });
124
- });
@@ -1,68 +0,0 @@
1
- import React from 'react';
2
- import { mount } from 'enzyme';
3
- import FormElement from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const inputProps = {
6
- htmlFor: 'test-input'
7
- };
8
- describe('<FormElement />', () => {
9
- // Simple tests for snapshots
10
- const tests = {
11
- 'should render a form element with no children': {
12
- props: {}
13
- },
14
- 'should render a form element with 1 child': {
15
- props: {
16
- children: [/*#__PURE__*/_jsx("input", {}, "test-key")]
17
- }
18
- },
19
- 'should render a focused form element': {
20
- props: {
21
- isFocused: true
22
- }
23
- },
24
- 'should show the label': {
25
- props: {
26
- label: 'The label'
27
- },
28
- find: 'Label',
29
- equal: 'The label'
30
- },
31
- 'should show the error message': {
32
- props: {
33
- errorText: 'The error text'
34
- },
35
- find: 'ErrorText',
36
- equal: 'The error text'
37
- },
38
- 'should show the placeholder text': {
39
- props: {
40
- placeholder: 'The placeholder'
41
- },
42
- find: 'Placeholder',
43
- equal: 'The placeholder'
44
- }
45
- };
46
- Object.keys(tests).forEach(test => {
47
- it(test, () => {
48
- const testFixtures = tests[test];
49
- const wrapper = mount(/*#__PURE__*/_jsx(FormElement, {
50
- ...inputProps,
51
- ...testFixtures.props
52
- }));
53
- expect(wrapper).toMatchSnapshot();
54
- if (testFixtures.find) {
55
- expect(wrapper.find(testFixtures.find).find('Translate').props().string).toEqual(testFixtures.equal);
56
- }
57
- });
58
- });
59
- it('Should hide placeholder with hasValue', () => {
60
- const wrapper = mount(/*#__PURE__*/_jsx(FormElement, {
61
- label: "testlabel",
62
- ...inputProps,
63
- hasValue: true
64
- }));
65
- expect(wrapper).toMatchSnapshot();
66
- expect(wrapper.find('Placeholder').props().visible).toEqual(false);
67
- });
68
- });
package/Glow/spec.js DELETED
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import Glow from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- describe('<Glow />', () => {
6
- it('should render with a smile', () => {
7
- const wrapper = render(/*#__PURE__*/_jsx(Glow, {
8
- children: /*#__PURE__*/_jsx("p", {
9
- children: "Glowing!"
10
- })
11
- }));
12
- expect(wrapper.asFragment()).toMatchSnapshot();
13
- });
14
- });
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { shallow, mount } from 'enzyme';
3
- import IndicatorCircle from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- describe('<IndicatorCircle />', () => {
6
- it('should apply the given size', () => {
7
- const wrapper = shallow(/*#__PURE__*/_jsx(IndicatorCircle, {
8
- size: 32
9
- }));
10
- expect(wrapper).toMatchSnapshot();
11
- const svg = wrapper.find('svg');
12
- expect(svg.props().width).toBe(32);
13
- expect(svg.props().height).toBe(32);
14
- });
15
- it('should apply the given color', () => {
16
- const wrapper = mount(/*#__PURE__*/_jsx(IndicatorCircle, {
17
- size: 32,
18
- color: "#fff",
19
- strokeWidth: 4
20
- }));
21
- expect(wrapper).toMatchSnapshot();
22
- const circleHtml = wrapper.find('circle');
23
- expect(circleHtml.html()).toMatch(/class="[^"]*"/);
24
- expect(circleHtml.html()).not.toEqual('');
25
- });
26
- });
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { mount } from 'enzyme';
3
- import PlaceholderLabel from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- describe('<PlaceholderLabel />', () => {
6
- it('should render placeholder ', () => {
7
- const wrapper = mount(/*#__PURE__*/_jsx(PlaceholderLabel, {
8
- ready: false,
9
- children: /*#__PURE__*/_jsx("h1", {
10
- children: "foo"
11
- })
12
- }));
13
- expect(wrapper).toMatchSnapshot();
14
- expect(wrapper.find('h1').length).toEqual(0);
15
- });
16
- it('should render children', () => {
17
- const wrapper = mount(/*#__PURE__*/_jsx(PlaceholderLabel, {
18
- ready: true,
19
- children: /*#__PURE__*/_jsx("h1", {
20
- children: "foo"
21
- })
22
- }));
23
- expect(wrapper).toMatchSnapshot();
24
- expect(wrapper.find('h1').length).toEqual(1);
25
- });
26
- });
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { mount } from 'enzyme';
3
- import PlaceholderParagraph from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- describe('<PlaceholderParagraph />', () => {
6
- it('should render placeholder ', () => {
7
- const wrapper = mount(/*#__PURE__*/_jsx(PlaceholderParagraph, {
8
- ready: false,
9
- children: /*#__PURE__*/_jsx("h1", {
10
- children: "foo"
11
- })
12
- }));
13
- expect(wrapper).toMatchSnapshot();
14
- expect(wrapper.find('h1').length).toEqual(0);
15
- });
16
- it('should render children', () => {
17
- const wrapper = mount(/*#__PURE__*/_jsx(PlaceholderParagraph, {
18
- ready: true,
19
- children: /*#__PURE__*/_jsx("h1", {
20
- children: "foo"
21
- })
22
- }));
23
- expect(wrapper).toMatchSnapshot();
24
- expect(wrapper.find('h1').length).toEqual(1);
25
- });
26
- });
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import Transition from 'react-transition-group/Transition';
4
- import ProgressBar from "./index";
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- describe('<ProgressBar />', () => {
7
- it('renders an indeterminate progress bar.', () => {
8
- const wrapper = shallow(/*#__PURE__*/_jsx(ProgressBar, {
9
- isVisible: true
10
- }));
11
- expect(wrapper).toMatchSnapshot();
12
- expect(wrapper.find(Transition).length).toBe(1);
13
- });
14
- });
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import { mount } from 'enzyme';
3
- import CheckedIcon from "../icons/RadioCheckedIcon";
4
- import UncheckedIcon from "../icons/RadioUncheckedIcon";
5
- import RadioButton from "./index";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- describe('RadioButton', () => {
8
- it('should render selected RadioButton', () => {
9
- const wrapper = mount(/*#__PURE__*/_jsx(RadioButton, {
10
- checked: true
11
- }));
12
- expect(wrapper.find(CheckedIcon).exists()).toBe(true);
13
- expect(wrapper.find(UncheckedIcon).exists()).toBe(false);
14
- expect(wrapper).toMatchSnapshot();
15
- });
16
- it('should render unselected RadioButton', () => {
17
- const wrapper = mount(/*#__PURE__*/_jsx(RadioButton, {}));
18
- expect(wrapper.find(CheckedIcon).exists()).toBe(false);
19
- expect(wrapper.find(UncheckedIcon).exists()).toBe(true);
20
- expect(wrapper).toMatchSnapshot();
21
- });
22
- });
@@ -1,91 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
4
- import StarIcon from "../icons/StarIcon";
5
- import StarHalfIcon from "../icons/StarHalfIcon";
6
- import RatingStars from "./index";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- const numEmptyStars = 5;
9
- describe('<RatingStars />', () => {
10
- it('renders with value of 50', () => {
11
- const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
12
- value: 50
13
- }), mockRenderOptions);
14
- expect(wrapper).toMatchSnapshot();
15
- expect(wrapper.find(StarIcon).length).toBe(numEmptyStars + 2);
16
- expect(wrapper.find(StarHalfIcon).length).toBe(1);
17
- });
18
- it('renders with value of 0', () => {
19
- const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
20
- value: 0
21
- }), mockRenderOptions);
22
- expect(wrapper).toMatchSnapshot();
23
- expect(wrapper.find(StarIcon).length).toBe(numEmptyStars);
24
- expect(wrapper.find(StarHalfIcon).length).toBe(0);
25
- });
26
- it('renders with value of 100', () => {
27
- const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
28
- value: 100
29
- }), mockRenderOptions);
30
- expect(wrapper).toMatchSnapshot();
31
- expect(wrapper.find(StarIcon).length).toBe(numEmptyStars + 5);
32
- expect(wrapper.find(StarHalfIcon).length).toBe(0);
33
- });
34
- it('should change rating on click', () => {
35
- const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
36
- value: 100,
37
- isSelectable: true
38
- }), mockRenderOptions);
39
- expect(wrapper).toMatchSnapshot();
40
- expect(wrapper.find(StarIcon).length).toBe(10);
41
- wrapper.setProps({
42
- value: 20
43
- });
44
- expect(wrapper.find(StarIcon).length).toBe(6);
45
- wrapper.setProps({
46
- value: 70
47
- });
48
- expect(wrapper.find(StarIcon).length).toBe(8);
49
- expect(wrapper.find(StarHalfIcon).length).toBe(1);
50
- expect(wrapper).toMatchSnapshot();
51
- });
52
- it('should call onSelection callback when component is selectable', () => {
53
- const spy = jest.fn();
54
- const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
55
- value: 100,
56
- isSelectable: true,
57
- onSelection: e => {
58
- wrapper.setProps({
59
- value: e.target.value
60
- });
61
- spy();
62
- }
63
- }), mockRenderOptions);
64
- // Click on 1 filled star.
65
- wrapper.find('[role="button"]').at(5).simulate('click', {
66
- target: {
67
- value: 10
68
- }
69
- });
70
- expect(spy.mock.calls.length).toBe(1);
71
- expect(wrapper.find('[role="button"]').length).toBe(6);
72
- // Click on 4th empty star
73
- wrapper.find('[role="button"]').at(3).simulate('click', {
74
- target: {
75
- value: 80
76
- }
77
- });
78
- expect(wrapper.find('[role="button"]').length).toBe(9);
79
- expect(spy.mock.calls.length).toBe(2);
80
- });
81
- it('should NOT call onSelection callback when component is NOT selectable', () => {
82
- const spy = jest.fn();
83
- const wrapper = shallow(/*#__PURE__*/_jsx(RatingStars, {
84
- value: 100,
85
- onSelection: spy
86
- }), mockRenderOptions);
87
- wrapper.find(StarIcon).at(5).parent('div').simulate('click');
88
- expect(wrapper.find('[role="button"]').length).toBe(0);
89
- expect(spy.mock.calls.length).toBe(0);
90
- });
91
- });
@@ -1,58 +0,0 @@
1
- import trim from 'lodash/trim';
2
- import React from 'react';
3
- import { mount } from 'enzyme';
4
- import BaseButton from '@shopgate/pwa-common/components/Button';
5
- import Ripple from "../Ripple";
6
- import RippleButton from "./index";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- describe('<RippleButton />', () => {
9
- it('should render as a regular ripple button effect if type is omitted', () => {
10
- const wrapper = mount(/*#__PURE__*/_jsx(RippleButton, {
11
- children: "Press me"
12
- }));
13
- expect(wrapper).toMatchSnapshot();
14
- expect(wrapper.find(Ripple).text()).toEqual('Press me');
15
- });
16
- it('should render as a regular ripple button if type is explicitly defined', () => {
17
- const wrapper = mount(/*#__PURE__*/_jsx(RippleButton, {
18
- type: "regular",
19
- children: "Press me"
20
- }));
21
- const base = wrapper.find(BaseButton);
22
- expect(base.exists()).toBe(true);
23
- expect(trim(base.props().className)).toMatch(/^ui-shared__button /);
24
- expect(trim(base.props().className)).toContain('ui-shared__ripple-button');
25
- expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
26
- expect(wrapper).toMatchSnapshot();
27
- });
28
- it('should render as a primary ripple button', () => {
29
- const wrapper = mount(/*#__PURE__*/_jsx(RippleButton, {
30
- type: "primary",
31
- children: "Press me"
32
- }));
33
- const base = wrapper.find(BaseButton);
34
- expect(trim(base.props().className)).toMatch(/^ui-shared__button /);
35
- expect(trim(base.props().className)).toContain('ui-shared__ripple-button');
36
- expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
37
- expect(wrapper).toMatchSnapshot();
38
- });
39
- it('should render as a secondary ripple button', () => {
40
- const wrapper = mount(/*#__PURE__*/_jsx(RippleButton, {
41
- type: "secondary",
42
- children: "Press me"
43
- }));
44
- const base = wrapper.find(BaseButton);
45
- expect(trim(base.props().className)).toMatch(/^ui-shared__button /);
46
- expect(trim(base.props().className)).toContain('ui-shared__ripple-button');
47
- expect(wrapper.find(Ripple).render().text()).toEqual('Press me');
48
- expect(wrapper).toMatchSnapshot();
49
- });
50
- it('should render as a disabled ripple button', () => {
51
- const wrapper = mount(/*#__PURE__*/_jsx(RippleButton, {
52
- disabled: true,
53
- children: "Press me"
54
- }));
55
- expect(wrapper.find(BaseButton).props().disabled).toBe(true);
56
- expect(wrapper).toMatchSnapshot();
57
- });
58
- });
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import { mount } from 'enzyme';
3
- import SearchBar from "./index";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- describe('<SearchBar />', () => {
6
- it('should call handleChange on input', async () => {
7
- const handleChange = jest.fn();
8
- const wrapper = await mount(/*#__PURE__*/_jsx(SearchBar, {
9
- handleChange: handleChange
10
- }));
11
- expect(wrapper).toMatchSnapshot();
12
- // Update input
13
- wrapper.find('input').first().simulate('change', {
14
- target: {
15
- name: 'search',
16
- value: 'asdf'
17
- }
18
- });
19
- // Should call with updated state.
20
- expect(handleChange).toHaveBeenCalledWith('asdf');
21
- });
22
- });