@zohodesk/components 1.6.7 → 1.6.11-exp-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/README.md +15 -0
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +68 -0
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +68 -0
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +68 -0
- package/es/Buttongroup/Buttongroup.module.css +10 -30
- package/es/CheckBox/CheckBox.module.css +3 -10
- package/es/DateTime/DateTime.module.css +22 -35
- package/es/DateTime/YearView.module.css +8 -10
- package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +3 -2
- package/es/DropDown/DropDown.module.css +2 -1
- package/es/DropDown/DropDownItem.module.css +1 -8
- package/es/DropDown/DropDownSeparator.module.css +2 -1
- package/es/ListItem/ListItem.module.css +4 -15
- package/es/MultiSelect/MobileHeader/MobileHeader.module.css +3 -2
- package/es/MultiSelect/MultiSelect.module.css +21 -34
- package/es/MultiSelect/SelectedOptions.module.css +6 -10
- package/es/Radio/Radio.module.css +3 -3
- package/es/ResponsiveDropBox/ResponsiveDropBox.module.css +1 -1
- package/es/Ribbon/Ribbon.module.css +9 -12
- package/es/Select/Select.module.css +22 -17
- package/es/Switch/Switch.module.css +1 -8
- package/es/Tab/Tab.module.css +8 -15
- package/es/Tab/Tabs.module.css +12 -22
- package/es/Tag/Tag.module.css +4 -3
- package/es/Tooltip/Tooltip.module.css +3 -2
- package/es/Typography/Typography.js +18 -8
- package/es/Typography/__tests__/Typography.spec.js +198 -6
- package/es/Typography/__tests__/__snapshots__/Typography.spec.js.snap +1235 -2
- package/es/Typography/css/Typography.module.css +4 -0
- package/es/Typography/css/cssJSLogic.js +53 -21
- package/es/Typography/props/defaultProps.js +4 -3
- package/es/Typography/props/propTypes.js +68 -26
- package/es/Typography/utils/textHighlighter.js +4 -2
- package/es/shared/ArrowIcon/ArrowIcon.module.css +3 -2
- package/es/v1/Button/Button.js +201 -0
- package/es/v1/Button/README.md +110 -0
- package/es/v1/Button/__tests__/Button.spec.js +272 -0
- package/es/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1160 -0
- package/es/v1/Button/_shared/Loader/Loader.js +33 -0
- package/es/v1/Button/_shared/Loader/Loader.module.css +42 -0
- package/es/v1/Button/_shared/Loader/__tests__/Loader.spec.js +21 -0
- package/es/v1/Button/_shared/Loader/__tests__/__snapshots__/Loader.spec.js.snap +49 -0
- package/es/v1/Button/_shared/Loader/props/defaultProps.js +4 -0
- package/es/v1/Button/_shared/Loader/props/propTypes.js +7 -0
- package/es/v1/Button/_shared/SuccessTick/SuccessTick.js +25 -0
- package/es/v1/Button/_shared/SuccessTick/SuccessTick.module.css +21 -0
- package/es/v1/Button/_shared/SuccessTick/__tests__/SuccessTick.spec.js +21 -0
- package/es/v1/Button/_shared/SuccessTick/__tests__/__snapshots__/SuccessTick.spec.js.snap +31 -0
- package/es/v1/Button/_shared/SuccessTick/props/defaultProps.js +4 -0
- package/es/v1/Button/_shared/SuccessTick/props/propTypes.js +7 -0
- package/es/v1/Button/constants/index.js +82 -0
- package/es/v1/Button/css/Button_v1.module.css +119 -0
- package/es/v1/Button/css/cssJSLogic.js +96 -0
- package/es/v1/Button/index.js +2 -0
- package/es/v1/Button/props/defaultProps.js +26 -0
- package/es/v1/Button/props/propTypes.js +43 -0
- package/es/v1/helpers/colorHelpers/background/backgroundColor.module.css +629 -0
- package/es/v1/helpers/colorHelpers/border/borderColor.module.css +489 -0
- package/es/v1/helpers/colorHelpers/colorHelper.js +176 -0
- package/es/v1/helpers/colorHelpers/constants/index.js +79 -0
- package/es/v1/helpers/colorHelpers/index.js +4 -0
- package/es/v1/helpers/colorHelpers/paletteUtilities.README.md +415 -0
- package/es/v1/helpers/colorHelpers/text/textColor.module.css +368 -0
- package/lib/Buttongroup/Buttongroup.module.css +10 -30
- package/lib/CheckBox/CheckBox.module.css +3 -10
- package/lib/DateTime/DateTime.module.css +22 -35
- package/lib/DateTime/YearView.module.css +8 -10
- package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +3 -2
- package/lib/DropDown/DropDown.module.css +2 -1
- package/lib/DropDown/DropDownItem.module.css +1 -8
- package/lib/DropDown/DropDownSeparator.module.css +2 -1
- package/lib/ListItem/ListItem.module.css +4 -15
- package/lib/MultiSelect/MobileHeader/MobileHeader.module.css +3 -2
- package/lib/MultiSelect/MultiSelect.module.css +21 -34
- package/lib/MultiSelect/SelectedOptions.module.css +6 -10
- package/lib/Radio/Radio.module.css +3 -3
- package/lib/ResponsiveDropBox/ResponsiveDropBox.module.css +1 -1
- package/lib/Ribbon/Ribbon.module.css +9 -12
- package/lib/Select/Select.module.css +22 -17
- package/lib/Switch/Switch.module.css +1 -8
- package/lib/Tab/Tab.module.css +8 -15
- package/lib/Tab/Tabs.module.css +12 -22
- package/lib/Tag/Tag.module.css +4 -3
- package/lib/Tooltip/Tooltip.module.css +3 -2
- package/lib/Typography/Typography.js +15 -5
- package/lib/Typography/__tests__/Typography.spec.js +284 -92
- package/lib/Typography/__tests__/__snapshots__/Typography.spec.js.snap +1235 -2
- package/lib/Typography/css/Typography.module.css +4 -0
- package/lib/Typography/css/cssJSLogic.js +38 -6
- package/lib/Typography/props/defaultProps.js +6 -3
- package/lib/Typography/props/propTypes.js +67 -23
- package/lib/Typography/utils/textHighlighter.js +6 -3
- package/lib/shared/ArrowIcon/ArrowIcon.module.css +3 -2
- package/lib/v1/Button/Button.js +239 -0
- package/lib/v1/Button/README.md +110 -0
- package/lib/v1/Button/__tests__/Button.spec.js +293 -0
- package/lib/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1160 -0
- package/lib/v1/Button/_shared/Loader/Loader.js +43 -0
- package/lib/v1/Button/_shared/Loader/Loader.module.css +42 -0
- package/lib/v1/Button/_shared/Loader/__tests__/Loader.spec.js +28 -0
- package/lib/v1/Button/_shared/Loader/__tests__/__snapshots__/Loader.spec.js.snap +49 -0
- package/lib/v1/Button/_shared/Loader/props/defaultProps.js +11 -0
- package/lib/v1/Button/_shared/Loader/props/propTypes.js +18 -0
- package/lib/v1/Button/_shared/SuccessTick/SuccessTick.js +35 -0
- package/lib/v1/Button/_shared/SuccessTick/SuccessTick.module.css +21 -0
- package/lib/v1/Button/_shared/SuccessTick/__tests__/SuccessTick.spec.js +28 -0
- package/lib/v1/Button/_shared/SuccessTick/__tests__/__snapshots__/SuccessTick.spec.js.snap +31 -0
- package/lib/v1/Button/_shared/SuccessTick/props/defaultProps.js +11 -0
- package/lib/v1/Button/_shared/SuccessTick/props/propTypes.js +18 -0
- package/lib/v1/Button/constants/index.js +114 -0
- package/lib/v1/Button/css/Button_v1.module.css +119 -0
- package/lib/v1/Button/css/cssJSLogic.js +88 -0
- package/lib/v1/Button/index.js +21 -0
- package/lib/v1/Button/props/defaultProps.js +36 -0
- package/lib/v1/Button/props/propTypes.js +56 -0
- package/lib/v1/helpers/colorHelpers/background/backgroundColor.module.css +629 -0
- package/lib/v1/helpers/colorHelpers/border/borderColor.module.css +489 -0
- package/lib/v1/helpers/colorHelpers/colorHelper.js +190 -0
- package/lib/v1/helpers/colorHelpers/constants/index.js +87 -0
- package/lib/v1/helpers/colorHelpers/index.js +57 -0
- package/lib/v1/helpers/colorHelpers/paletteUtilities.README.md +415 -0
- package/lib/v1/helpers/colorHelpers/text/textColor.module.css +368 -0
- package/package.json +9 -9
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cleanup, render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import Button from "../Button";
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
cleanup();
|
|
8
|
+
});
|
|
9
|
+
describe('Button - Component', () => {
|
|
10
|
+
test('Should render with the basic set of default props', () => {
|
|
11
|
+
const {
|
|
12
|
+
asFragment
|
|
13
|
+
} = render( /*#__PURE__*/React.createElement(Button, null));
|
|
14
|
+
expect(asFragment()).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
test('Should render with children', () => {
|
|
17
|
+
const {
|
|
18
|
+
asFragment
|
|
19
|
+
} = render( /*#__PURE__*/React.createElement(Button, null, "Click Me"));
|
|
20
|
+
expect(asFragment()).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
const palette = ['default', 'primary', 'secondary', 'danger', 'success'];
|
|
23
|
+
test.each(palette)('Should render palette of buttons - %s', palette => {
|
|
24
|
+
const {
|
|
25
|
+
asFragment
|
|
26
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
27
|
+
palette: palette
|
|
28
|
+
}));
|
|
29
|
+
expect(asFragment()).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
const bgAppearance = ['default', 'onHover', 'none'];
|
|
32
|
+
test.each(bgAppearance)('Should render bgAppearance of buttons - %s', bg => {
|
|
33
|
+
const {
|
|
34
|
+
asFragment
|
|
35
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
36
|
+
bgAppearance: bg
|
|
37
|
+
}));
|
|
38
|
+
expect(asFragment()).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
const borderAppearance = ['default', 'onHover', 'none'];
|
|
41
|
+
test.each(borderAppearance)('Should render borderAppearance of buttons - %s', border => {
|
|
42
|
+
const {
|
|
43
|
+
asFragment
|
|
44
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
45
|
+
borderAppearance: border
|
|
46
|
+
}));
|
|
47
|
+
expect(asFragment()).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
const variant = ['text', 'icon', 'iconWithText'];
|
|
50
|
+
test.each(variant)('Should render variant of buttons - %s', variant => {
|
|
51
|
+
const {
|
|
52
|
+
asFragment
|
|
53
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
54
|
+
variant: variant
|
|
55
|
+
}));
|
|
56
|
+
expect(asFragment()).toMatchSnapshot();
|
|
57
|
+
});
|
|
58
|
+
const size = ['small', 'medium', 'large', 'full'];
|
|
59
|
+
test.each(size)('Should render Sizes of buttons - %s', size => {
|
|
60
|
+
const {
|
|
61
|
+
asFragment
|
|
62
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
63
|
+
size: size
|
|
64
|
+
}));
|
|
65
|
+
expect(asFragment()).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
const status = ['default', 'loading', 'success'];
|
|
68
|
+
test.each(status)('Should render Status of buttons - %s', status => {
|
|
69
|
+
const {
|
|
70
|
+
asFragment
|
|
71
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
72
|
+
status: status
|
|
73
|
+
}));
|
|
74
|
+
expect(asFragment()).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
const loaderPlacement = ['start', 'end', 'overlay'];
|
|
77
|
+
test.each(loaderPlacement)('Should render loaderPlacement of buttons - %s', loaderPlacement => {
|
|
78
|
+
const {
|
|
79
|
+
asFragment
|
|
80
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
81
|
+
status: "loading",
|
|
82
|
+
loaderPlacement: loaderPlacement
|
|
83
|
+
}));
|
|
84
|
+
expect(asFragment()).toMatchSnapshot();
|
|
85
|
+
});
|
|
86
|
+
test('Should render with iconName and iconSize ', () => {
|
|
87
|
+
const {
|
|
88
|
+
asFragment
|
|
89
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
90
|
+
variant: "icon",
|
|
91
|
+
iconName: "ZD-plus",
|
|
92
|
+
iconSize: 20
|
|
93
|
+
}));
|
|
94
|
+
expect(asFragment()).toMatchSnapshot();
|
|
95
|
+
});
|
|
96
|
+
test('Should render with iconPlacement ', () => {
|
|
97
|
+
const {
|
|
98
|
+
asFragment
|
|
99
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
100
|
+
variant: "iconWithText",
|
|
101
|
+
iconName: "ZD-plus",
|
|
102
|
+
iconPlacement: "right"
|
|
103
|
+
}, "Button"));
|
|
104
|
+
expect(asFragment()).toMatchSnapshot();
|
|
105
|
+
});
|
|
106
|
+
test('Should render with renderIcon', () => {
|
|
107
|
+
const {
|
|
108
|
+
asFragment
|
|
109
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
110
|
+
variant: "icon",
|
|
111
|
+
renderIcon: () => /*#__PURE__*/React.createElement("span", null, "CustomIcon")
|
|
112
|
+
}));
|
|
113
|
+
expect(asFragment()).toMatchSnapshot();
|
|
114
|
+
});
|
|
115
|
+
test('Should render with renderBefore and renderAfter', () => {
|
|
116
|
+
const {
|
|
117
|
+
asFragment
|
|
118
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
119
|
+
renderBefore: () => /*#__PURE__*/React.createElement("span", null, "Before"),
|
|
120
|
+
renderAfter: () => /*#__PURE__*/React.createElement("span", null, "After")
|
|
121
|
+
}, "Button"));
|
|
122
|
+
expect(asFragment()).toMatchSnapshot();
|
|
123
|
+
});
|
|
124
|
+
test('Should render with renderLoader', () => {
|
|
125
|
+
const {
|
|
126
|
+
asFragment
|
|
127
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
128
|
+
status: "loading",
|
|
129
|
+
renderLoader: () => /*#__PURE__*/React.createElement("span", null, "Loading...")
|
|
130
|
+
}));
|
|
131
|
+
expect(asFragment()).toMatchSnapshot();
|
|
132
|
+
});
|
|
133
|
+
test('Should render with renderSuccess', () => {
|
|
134
|
+
const {
|
|
135
|
+
asFragment
|
|
136
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
137
|
+
status: "success",
|
|
138
|
+
renderSuccess: () => /*#__PURE__*/React.createElement("span", null, "Success!")
|
|
139
|
+
}));
|
|
140
|
+
expect(asFragment()).toMatchSnapshot();
|
|
141
|
+
});
|
|
142
|
+
const type = ['button', 'submit', 'reset'];
|
|
143
|
+
test.each(type)('Should render type of buttons - %s', type => {
|
|
144
|
+
const {
|
|
145
|
+
asFragment
|
|
146
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
147
|
+
type: type
|
|
148
|
+
}));
|
|
149
|
+
expect(asFragment()).toMatchSnapshot();
|
|
150
|
+
});
|
|
151
|
+
test('Should trigger onClick function', () => {
|
|
152
|
+
const onClick = jest.fn();
|
|
153
|
+
const {
|
|
154
|
+
getByRole
|
|
155
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
156
|
+
onClick: onClick
|
|
157
|
+
}));
|
|
158
|
+
userEvent.click(getByRole('button'));
|
|
159
|
+
expect(onClick).toHaveBeenCalled();
|
|
160
|
+
});
|
|
161
|
+
test('Should be disabled when isDisabled prop is true', () => {
|
|
162
|
+
const {
|
|
163
|
+
asFragment
|
|
164
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
165
|
+
isDisabled: true
|
|
166
|
+
}));
|
|
167
|
+
expect(asFragment()).toMatchSnapshot();
|
|
168
|
+
});
|
|
169
|
+
test('Should render with readOnly style when isReadOnly prop is true', () => {
|
|
170
|
+
const {
|
|
171
|
+
asFragment
|
|
172
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
173
|
+
isReadOnly: true
|
|
174
|
+
}));
|
|
175
|
+
expect(asFragment()).toMatchSnapshot();
|
|
176
|
+
});
|
|
177
|
+
test('Should render with selected style when isSelected prop is true', () => {
|
|
178
|
+
const {
|
|
179
|
+
asFragment
|
|
180
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
181
|
+
isSelected: true
|
|
182
|
+
}));
|
|
183
|
+
expect(asFragment()).toMatchSnapshot();
|
|
184
|
+
});
|
|
185
|
+
const shape = ['pill', 'rectangle', 'roundedRectangle'];
|
|
186
|
+
test.each(shape)('Should render shape of buttons - %s', shape => {
|
|
187
|
+
const {
|
|
188
|
+
asFragment
|
|
189
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
190
|
+
shape: shape
|
|
191
|
+
}));
|
|
192
|
+
expect(asFragment()).toMatchSnapshot();
|
|
193
|
+
});
|
|
194
|
+
const paletteShade = ['default', 'lighter'];
|
|
195
|
+
test.each(paletteShade)('Should render paletteShade of buttons - %s', shade => {
|
|
196
|
+
const {
|
|
197
|
+
asFragment
|
|
198
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
199
|
+
paletteShade: shade
|
|
200
|
+
}));
|
|
201
|
+
expect(asFragment()).toMatchSnapshot();
|
|
202
|
+
});
|
|
203
|
+
const disabledAppearance = ['none', 'dull', 'strike'];
|
|
204
|
+
test.each(disabledAppearance)('Should render disabledAppearance of buttons - %s', style => {
|
|
205
|
+
const {
|
|
206
|
+
asFragment
|
|
207
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
208
|
+
isDisabled: true,
|
|
209
|
+
disabledAppearance: style
|
|
210
|
+
}));
|
|
211
|
+
expect(asFragment()).toMatchSnapshot();
|
|
212
|
+
});
|
|
213
|
+
test('Should render with title attribute', () => {
|
|
214
|
+
const {
|
|
215
|
+
asFragment
|
|
216
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
217
|
+
title: "Button test title"
|
|
218
|
+
}));
|
|
219
|
+
expect(asFragment()).toMatchSnapshot();
|
|
220
|
+
});
|
|
221
|
+
test('Should apply customClass to wrapper and text', () => {
|
|
222
|
+
const {
|
|
223
|
+
asFragment
|
|
224
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
225
|
+
customClass: {
|
|
226
|
+
wrapper: 'customButtonClass',
|
|
227
|
+
text: 'customTextClass'
|
|
228
|
+
}
|
|
229
|
+
}, "Button"));
|
|
230
|
+
expect(asFragment()).toMatchSnapshot();
|
|
231
|
+
});
|
|
232
|
+
test('Should apply customProps to wrapper, text and icon', () => {
|
|
233
|
+
const {
|
|
234
|
+
asFragment
|
|
235
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
236
|
+
variant: "iconWithText",
|
|
237
|
+
iconName: "check",
|
|
238
|
+
customProps: {
|
|
239
|
+
wrapper: {
|
|
240
|
+
'data-wrapper': 'wrapperProps'
|
|
241
|
+
},
|
|
242
|
+
text: {
|
|
243
|
+
'data-text': 'textProps'
|
|
244
|
+
},
|
|
245
|
+
icon: {
|
|
246
|
+
'data-icon': 'iconProps'
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}, "Button"));
|
|
250
|
+
expect(asFragment()).toMatchSnapshot();
|
|
251
|
+
});
|
|
252
|
+
test('Should render with customId and testId', () => {
|
|
253
|
+
const {
|
|
254
|
+
asFragment
|
|
255
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
256
|
+
customId: "customIdValue",
|
|
257
|
+
testId: "testIdValue"
|
|
258
|
+
}));
|
|
259
|
+
expect(asFragment()).toMatchSnapshot();
|
|
260
|
+
});
|
|
261
|
+
test('Should apply a11yAttributes to the button', () => {
|
|
262
|
+
const {
|
|
263
|
+
asFragment
|
|
264
|
+
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
265
|
+
a11yAttributes: {
|
|
266
|
+
'aria-label': 'Smart Button',
|
|
267
|
+
'aria-describedby': 'button-description'
|
|
268
|
+
}
|
|
269
|
+
}, "Button"));
|
|
270
|
+
expect(asFragment()).toMatchSnapshot();
|
|
271
|
+
});
|
|
272
|
+
});
|