@shopgate/pwa-ui-shared 7.32.0-beta.9 → 7.32.0
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/DiscountBadge/index.js +1 -1
- package/FavoritesButton/FavoritesButton.d.ts +74 -0
- package/FavoritesButton/FavoritesButton.d.ts.map +1 -0
- package/FavoritesButton/FavoritesButton.js +87 -0
- package/FavoritesButton/connector.d.ts +3 -0
- package/FavoritesButton/connector.d.ts.map +1 -0
- package/FavoritesButton/index.d.ts +3 -0
- package/FavoritesButton/index.d.ts.map +1 -0
- package/FavoritesButton/index.js +1 -134
- package/Glow/index.js +4 -3
- package/NoResults/components/Icon/index.js +4 -1
- package/Price/index.js +11 -4
- package/PriceStriked/index.js +7 -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 -105
- 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 -94
- 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/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
|
-
});
|
package/ToggleIcon/spec.js
DELETED
|
@@ -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
|
-
});
|
package/tsconfig.build.json
DELETED
|
@@ -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