cpk-ui 0.5.4 → 0.7.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/README.md +80 -147
- package/components/modals/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/components/modals/AlertDialog/AlertDialog.js +14 -7
- package/components/modals/Snackbar/Snackbar.d.ts.map +1 -1
- package/components/modals/Snackbar/Snackbar.js +20 -17
- package/components/uis/Accordion/AccordionItem.d.ts.map +1 -1
- package/components/uis/Accordion/AccordionItem.js +41 -17
- package/components/uis/Button/Button.d.ts +2 -1
- package/components/uis/Button/Button.d.ts.map +1 -1
- package/components/uis/Button/Button.js +11 -11
- package/components/uis/Card/Card.d.ts +2 -1
- package/components/uis/Card/Card.d.ts.map +1 -1
- package/components/uis/Card/Card.js +12 -3
- package/components/uis/Checkbox/Checkbox.d.ts +2 -1
- package/components/uis/Checkbox/Checkbox.d.ts.map +1 -1
- package/components/uis/Checkbox/Checkbox.js +2 -2
- package/components/uis/CustomPressable/CustomPressable.d.ts.map +1 -1
- package/components/uis/CustomPressable/CustomPressable.js +6 -6
- package/components/uis/EditText/EditText.d.ts +1 -0
- package/components/uis/EditText/EditText.d.ts.map +1 -1
- package/components/uis/EditText/EditText.js +18 -13
- package/components/uis/Fab/Fab.d.ts +2 -2
- package/components/uis/Fab/Fab.d.ts.map +1 -1
- package/components/uis/Fab/Fab.js +22 -4
- package/components/uis/Icon/Icon.d.ts.map +1 -1
- package/components/uis/Icon/Icon.js +6 -3
- package/components/uis/IconButton/IconButton.d.ts +2 -1
- package/components/uis/IconButton/IconButton.d.ts.map +1 -1
- package/components/uis/IconButton/IconButton.js +44 -42
- package/components/uis/LoadingIndicator/LoadingIndicator.d.ts +2 -1
- package/components/uis/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
- package/components/uis/LoadingIndicator/LoadingIndicator.js +4 -4
- package/components/uis/RadioGroup/RadioButton.d.ts +2 -1
- package/components/uis/RadioGroup/RadioButton.d.ts.map +1 -1
- package/components/uis/RadioGroup/RadioButton.js +2 -2
- package/components/uis/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/components/uis/RadioGroup/RadioGroup.js +16 -3
- package/components/uis/Rating/Rating.d.ts.map +1 -1
- package/components/uis/Rating/Rating.js +23 -19
- package/components/uis/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/components/uis/SegmentedControl/SegmentedControl.js +1 -1
- package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts +2 -2
- package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts.map +1 -1
- package/components/uis/StatusbarBrightness/StatusBarBrightness.js +1 -1
- package/components/uis/SwitchToggle/SwitchToggle.d.ts +2 -1
- package/components/uis/SwitchToggle/SwitchToggle.d.ts.map +1 -1
- package/components/uis/SwitchToggle/SwitchToggle.js +2 -2
- package/hooks/useHoverState.d.ts +8 -0
- package/hooks/useHoverState.d.ts.map +1 -0
- package/hooks/useHoverState.js +16 -0
- package/package.json +18 -6
- package/providers/ThemeProvider.d.ts.map +1 -1
- package/providers/ThemeProvider.js +0 -1
- package/providers/index.d.ts.map +1 -1
- package/providers/index.js +3 -2
- package/components/uis/Icon/selection.json +0 -1
- package/src/components/common/ErrorBoundary/ErrorBoundary.tsx +0 -75
- package/src/components/modals/AlertDialog/AlertDialog.stories.tsx +0 -216
- package/src/components/modals/AlertDialog/AlertDialog.test.tsx +0 -251
- package/src/components/modals/AlertDialog/AlertDialog.tsx +0 -356
- package/src/components/modals/Snackbar/Snackbar.stories.tsx +0 -182
- package/src/components/modals/Snackbar/Snackbar.test.tsx +0 -319
- package/src/components/modals/Snackbar/Snackbar.tsx +0 -260
- package/src/components/modals/Snackbar/const.ts +0 -4
- package/src/components/uis/Accordion/Accordion.stories.tsx +0 -167
- package/src/components/uis/Accordion/Accordion.test.tsx +0 -272
- package/src/components/uis/Accordion/Accordion.tsx +0 -109
- package/src/components/uis/Accordion/AccordionItem.tsx +0 -306
- package/src/components/uis/Button/Button.stories.tsx +0 -218
- package/src/components/uis/Button/Button.test.tsx +0 -620
- package/src/components/uis/Button/Button.tsx +0 -436
- package/src/components/uis/Card/Card.test.tsx +0 -146
- package/src/components/uis/Card/Card.tsx +0 -102
- package/src/components/uis/Checkbox/Checkbox.stories.tsx +0 -216
- package/src/components/uis/Checkbox/Checkbox.test.tsx +0 -173
- package/src/components/uis/Checkbox/Checkbox.tsx +0 -220
- package/src/components/uis/CustomPressable/CustomPressable.tsx +0 -48
- package/src/components/uis/EditText/EditText.stories.tsx +0 -124
- package/src/components/uis/EditText/EditText.test.tsx +0 -477
- package/src/components/uis/EditText/EditText.tsx +0 -590
- package/src/components/uis/Fab/Fab.stories.tsx +0 -133
- package/src/components/uis/Fab/Fab.test.tsx +0 -110
- package/src/components/uis/Fab/Fab.tsx +0 -168
- package/src/components/uis/Hr/Hr.test.tsx +0 -26
- package/src/components/uis/Hr/Hr.tsx +0 -19
- package/src/components/uis/Icon/Icon.stories.tsx +0 -98
- package/src/components/uis/Icon/Icon.test.tsx +0 -49
- package/src/components/uis/Icon/Icon.tsx +0 -3819
- package/src/components/uis/IconButton/IconButton.test.tsx +0 -165
- package/src/components/uis/IconButton/IconButton.tsx +0 -275
- package/src/components/uis/LoadingIndicator/LoadingIndicator.tsx +0 -126
- package/src/components/uis/LoadingIndicator/LodingIndicator.stories.tsx +0 -81
- package/src/components/uis/PinchZoom/PinchZoom.stories.tsx +0 -266
- package/src/components/uis/PinchZoom/PinchZoom.test.tsx +0 -113
- package/src/components/uis/PinchZoom/PinchZoom.tsx +0 -424
- package/src/components/uis/RadioGroup/RadioButton.tsx +0 -188
- package/src/components/uis/RadioGroup/RadioGroup.stories.tsx +0 -188
- package/src/components/uis/RadioGroup/RadioGroup.test.tsx +0 -287
- package/src/components/uis/RadioGroup/RadioGroup.tsx +0 -109
- package/src/components/uis/Rating/Rating.test.tsx +0 -98
- package/src/components/uis/Rating/Rating.tsx +0 -200
- package/src/components/uis/SegmentedControl/SegmentedControl.stories.tsx +0 -546
- package/src/components/uis/SegmentedControl/SegmentedControl.test.tsx +0 -274
- package/src/components/uis/SegmentedControl/SegmentedControl.tsx +0 -229
- package/src/components/uis/StatusbarBrightness/StatusBarBrightness.test.tsx +0 -41
- package/src/components/uis/StatusbarBrightness/StatusBarBrightness.tsx +0 -26
- package/src/components/uis/Styled/StyledComponents.tsx +0 -217
- package/src/components/uis/SwitchToggle/SwitchToggle.stories.tsx +0 -75
- package/src/components/uis/SwitchToggle/SwitchToggle.test.tsx +0 -105
- package/src/components/uis/SwitchToggle/SwitchToggle.tsx +0 -305
- package/src/components/uis/Typography/Typography.stories.tsx +0 -149
- package/src/components/uis/Typography/Typography.test.tsx +0 -58
- package/src/components/uis/Typography/Typography.tsx +0 -386
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useAnimations.ts +0 -71
- package/src/hooks/useDebouncedColorScheme.tsx +0 -30
- package/src/hooks/useOptimizedStyles.ts +0 -22
- package/src/hooks/usePerformance.ts +0 -93
- package/src/index.tsx +0 -38
- package/src/providers/ThemeProvider.tsx +0 -177
- package/src/providers/index.tsx +0 -130
- package/src/test/testUtils.tsx +0 -101
- package/src/types/common.ts +0 -77
- package/src/types/index.ts +0 -1
- package/src/types/kstyled.d.ts +0 -6
- package/src/utils/accessibility.ts +0 -110
- package/src/utils/colors.ts +0 -151
- package/src/utils/createCtx.tsx +0 -26
- package/src/utils/guards.ts +0 -93
- package/src/utils/index.ts +0 -2
- package/src/utils/performanceTest.ts +0 -174
- package/src/utils/platform.ts +0 -69
- package/src/utils/theme.ts +0 -38
- package/test/testUtils.d.ts +0 -113
- package/test/testUtils.d.ts.map +0 -1
- package/test/testUtils.js +0 -65
|
@@ -1,620 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-native/extend-expect';
|
|
2
|
-
|
|
3
|
-
import React, {type ReactElement} from 'react';
|
|
4
|
-
import {Text} from 'react-native';
|
|
5
|
-
import {css} from 'kstyled';
|
|
6
|
-
import type {RenderAPI} from '@testing-library/react-native';
|
|
7
|
-
import {fireEvent, render} from '@testing-library/react-native';
|
|
8
|
-
|
|
9
|
-
import {createComponent} from '../../../../test/testUtils';
|
|
10
|
-
import {Button} from './Button';
|
|
11
|
-
import {LoadingIndicator} from '../LoadingIndicator/LoadingIndicator';
|
|
12
|
-
import type {Props as ButtonProps} from './Button';
|
|
13
|
-
import {ThemeType, ThemeProvider} from '../../../providers/ThemeProvider';
|
|
14
|
-
import {dark, light} from '../../../utils/colors';
|
|
15
|
-
|
|
16
|
-
let testingLib: RenderAPI;
|
|
17
|
-
|
|
18
|
-
jest.mock('react-native-web-hooks', () => ({
|
|
19
|
-
useHover: () => true,
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
const Component = ({
|
|
23
|
-
props,
|
|
24
|
-
themeType,
|
|
25
|
-
}: {
|
|
26
|
-
props?: ButtonProps;
|
|
27
|
-
themeType?: ThemeType;
|
|
28
|
-
}): ReactElement =>
|
|
29
|
-
createComponent(<Button onPress={jest.fn} {...props} />, themeType);
|
|
30
|
-
|
|
31
|
-
describe('[Button]', () => {
|
|
32
|
-
it('should render without crashing', () => {
|
|
33
|
-
testingLib = render(Component({}));
|
|
34
|
-
|
|
35
|
-
const json = testingLib.toJSON();
|
|
36
|
-
expect(json).toBeTruthy();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('Index', () => {
|
|
40
|
-
it('should render loading status', () => {
|
|
41
|
-
testingLib = render(Component({props: {loading: true}}));
|
|
42
|
-
|
|
43
|
-
expect(LoadingIndicator).toBeDefined();
|
|
44
|
-
expect(testingLib.getByTestId('loading-view')).toBeTruthy();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should render default disabled style when disabled', () => {
|
|
48
|
-
testingLib = render(Component({props: {disabled: true}}));
|
|
49
|
-
|
|
50
|
-
const loadingView = testingLib.getByTestId('button-container');
|
|
51
|
-
expect(loadingView).toHaveStyle({borderTopColor: light.text.disabled});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe('Disabled', () => {
|
|
56
|
-
it('should render disabled status', () => {
|
|
57
|
-
testingLib = render(Component({props: {disabled: true}}));
|
|
58
|
-
|
|
59
|
-
const json = testingLib.toJSON();
|
|
60
|
-
expect(json).toBeTruthy();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should render disabled status with disabled style', () => {
|
|
64
|
-
testingLib = render(
|
|
65
|
-
Component({
|
|
66
|
-
props: {
|
|
67
|
-
disabled: true,
|
|
68
|
-
styles: {
|
|
69
|
-
disabled: css`
|
|
70
|
-
background-color: yellow;
|
|
71
|
-
`,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
}),
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const button = testingLib.getByTestId('button-container');
|
|
78
|
-
expect(button).toHaveStyle({backgroundColor: 'yellow'});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should render container', () => {
|
|
82
|
-
testingLib = render(
|
|
83
|
-
Component({
|
|
84
|
-
props: {
|
|
85
|
-
styles: {
|
|
86
|
-
container: css`
|
|
87
|
-
background-color: blue;
|
|
88
|
-
`,
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
}),
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
const button = testingLib.getByTestId('button-container');
|
|
95
|
-
expect(button).toHaveStyle({backgroundColor: 'blue'});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe('TextButton', () => {
|
|
100
|
-
it('renders text button', () => {
|
|
101
|
-
testingLib = render(
|
|
102
|
-
Component({
|
|
103
|
-
props: {
|
|
104
|
-
testID: 'text-button',
|
|
105
|
-
type: 'text',
|
|
106
|
-
},
|
|
107
|
-
}),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const json = testingLib.toJSON();
|
|
111
|
-
expect(json).toBeTruthy();
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should render start and end elements', () => {
|
|
116
|
-
testingLib = render(
|
|
117
|
-
Component({props: {startElement: <Text />, endElement: <Text />}}),
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
const button = testingLib.getByTestId('button-container');
|
|
121
|
-
|
|
122
|
-
// @ts-ignore
|
|
123
|
-
expect(button.findAllByType(Text)).toHaveLength(3);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe('[Button] Interaction', () => {
|
|
127
|
-
let cnt = 1;
|
|
128
|
-
|
|
129
|
-
it('should simulate onPress', () => {
|
|
130
|
-
testingLib = render(
|
|
131
|
-
Component({
|
|
132
|
-
props: {
|
|
133
|
-
onPress: () => cnt++,
|
|
134
|
-
},
|
|
135
|
-
}),
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
const button = testingLib.getByTestId('button-container');
|
|
139
|
-
|
|
140
|
-
fireEvent.press(button);
|
|
141
|
-
|
|
142
|
-
expect(cnt).toBe(2);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe('[Button] color', () => {
|
|
147
|
-
it('should renders primary color', () => {
|
|
148
|
-
testingLib = render(Component({props: {color: 'primary'}}));
|
|
149
|
-
|
|
150
|
-
const button = testingLib.getByTestId('button-container');
|
|
151
|
-
expect(button).toHaveStyle({backgroundColor: light.button.primary.bg});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('should renders secondary color', () => {
|
|
155
|
-
testingLib = render(Component({props: {color: 'secondary'}}));
|
|
156
|
-
|
|
157
|
-
const button = testingLib.getByTestId('button-container');
|
|
158
|
-
expect(button).toHaveStyle({
|
|
159
|
-
backgroundColor: light.button.secondary.bg,
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('should renders success color', () => {
|
|
164
|
-
testingLib = render(Component({props: {color: 'success'}}));
|
|
165
|
-
|
|
166
|
-
const button = testingLib.getByTestId('button-container');
|
|
167
|
-
expect(button).toHaveStyle({backgroundColor: light.button.success.bg});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('should renders warning color', () => {
|
|
171
|
-
testingLib = render(Component({props: {color: 'warning'}}));
|
|
172
|
-
|
|
173
|
-
const button = testingLib.getByTestId('button-container');
|
|
174
|
-
expect(button).toHaveStyle({backgroundColor: light.button.warning.bg});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('renders danger color', () => {
|
|
178
|
-
testingLib = render(Component({props: {color: 'danger'}}));
|
|
179
|
-
|
|
180
|
-
const button = testingLib.getByTestId('button-container');
|
|
181
|
-
expect(button).toHaveStyle({backgroundColor: light.button.danger.bg});
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('should renders info color', () => {
|
|
185
|
-
testingLib = render(Component({props: {color: 'info'}}));
|
|
186
|
-
|
|
187
|
-
const button = testingLib.getByTestId('button-container');
|
|
188
|
-
expect(button).toHaveStyle({backgroundColor: light.button.info.bg});
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('should renders light color', () => {
|
|
192
|
-
testingLib = render(Component({props: {color: 'light'}}));
|
|
193
|
-
|
|
194
|
-
const button = testingLib.getByTestId('button-container');
|
|
195
|
-
expect(button).toHaveStyle({backgroundColor: light.button.light.bg});
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
describe('[Button] - dark mode', () => {
|
|
200
|
-
it('should render button', () => {
|
|
201
|
-
testingLib = render(Component({themeType: 'dark'}));
|
|
202
|
-
|
|
203
|
-
const button = testingLib.getByTestId('button-container');
|
|
204
|
-
expect(button).toHaveStyle({backgroundColor: dark.button.primary.bg});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('should renders danger color', () => {
|
|
208
|
-
testingLib = render(
|
|
209
|
-
Component({
|
|
210
|
-
props: {
|
|
211
|
-
text: 'my-button',
|
|
212
|
-
color: 'danger',
|
|
213
|
-
},
|
|
214
|
-
themeType: 'dark',
|
|
215
|
-
}),
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
const button = testingLib.getByTestId('button-container');
|
|
219
|
-
expect(button).toHaveStyle({backgroundColor: dark.button.danger.bg});
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
describe('[Button] outlined', () => {
|
|
224
|
-
it('should render [type=outlined] button', () => {
|
|
225
|
-
testingLib = render(
|
|
226
|
-
Component({
|
|
227
|
-
props: {type: 'outlined'},
|
|
228
|
-
}),
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
const button = testingLib.getByTestId('button-container');
|
|
232
|
-
expect(button).toHaveStyle({backgroundColor: light.bg.basic});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('should render [type=outlined] button with [color=primary]', () => {
|
|
236
|
-
testingLib = render(
|
|
237
|
-
Component({
|
|
238
|
-
props: {
|
|
239
|
-
type: 'outlined',
|
|
240
|
-
color: 'primary',
|
|
241
|
-
},
|
|
242
|
-
}),
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
const button = testingLib.getByTestId('button-container');
|
|
246
|
-
expect(button).toHaveStyle({
|
|
247
|
-
backgroundColor: light.bg.basic,
|
|
248
|
-
borderBottomColor: light.button.primary.bg,
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('should render [type=outlined] button with [color=secondary]', () => {
|
|
253
|
-
testingLib = render(
|
|
254
|
-
Component({
|
|
255
|
-
props: {
|
|
256
|
-
type: 'outlined',
|
|
257
|
-
color: 'secondary',
|
|
258
|
-
},
|
|
259
|
-
}),
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
const button = testingLib.getByTestId('button-container');
|
|
263
|
-
expect(button).toHaveStyle({
|
|
264
|
-
backgroundColor: light.bg.basic,
|
|
265
|
-
borderBottomColor: light.button.secondary.bg,
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
it('should render [type=outlined] button with [color=success]', () => {
|
|
270
|
-
testingLib = render(
|
|
271
|
-
Component({
|
|
272
|
-
props: {
|
|
273
|
-
type: 'outlined',
|
|
274
|
-
color: 'success',
|
|
275
|
-
},
|
|
276
|
-
}),
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
const button = testingLib.getByTestId('button-container');
|
|
280
|
-
|
|
281
|
-
expect(button).toHaveStyle({
|
|
282
|
-
backgroundColor: light.bg.basic,
|
|
283
|
-
borderBottomColor: light.button.success.bg,
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it('should render [type=outlined] button with [color=warning]', () => {
|
|
288
|
-
testingLib = render(
|
|
289
|
-
Component({
|
|
290
|
-
props: {
|
|
291
|
-
type: 'outlined',
|
|
292
|
-
color: 'warning',
|
|
293
|
-
},
|
|
294
|
-
}),
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
const button = testingLib.getByTestId('button-container');
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
expect(button).toHaveStyle({
|
|
301
|
-
backgroundColor: light.bg.basic,
|
|
302
|
-
borderBottomColor: light.button.warning.bg,
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it('should render [type=outlined] button with [color=danger]', () => {
|
|
307
|
-
testingLib = render(
|
|
308
|
-
Component({
|
|
309
|
-
props: {
|
|
310
|
-
type: 'outlined',
|
|
311
|
-
color: 'danger',
|
|
312
|
-
},
|
|
313
|
-
}),
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
const button = testingLib.getByTestId('button-container');
|
|
317
|
-
|
|
318
|
-
expect(button).toHaveStyle({
|
|
319
|
-
backgroundColor: light.bg.basic,
|
|
320
|
-
borderBottomColor: light.button.danger.bg,
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it('should render [type=outlined] button with [color=info]', () => {
|
|
325
|
-
testingLib = render(
|
|
326
|
-
Component({
|
|
327
|
-
props: {
|
|
328
|
-
type: 'outlined',
|
|
329
|
-
color: 'info',
|
|
330
|
-
},
|
|
331
|
-
}),
|
|
332
|
-
);
|
|
333
|
-
|
|
334
|
-
const button = testingLib.getByTestId('button-container');
|
|
335
|
-
|
|
336
|
-
expect(button).toHaveStyle({
|
|
337
|
-
backgroundColor: light.bg.basic,
|
|
338
|
-
borderBottomColor: light.button.info.bg,
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
it('should render [type=outlined] button with [color=light]', () => {
|
|
343
|
-
testingLib = render(
|
|
344
|
-
Component({
|
|
345
|
-
props: {
|
|
346
|
-
type: 'outlined',
|
|
347
|
-
color: 'light',
|
|
348
|
-
},
|
|
349
|
-
}),
|
|
350
|
-
);
|
|
351
|
-
|
|
352
|
-
const button = testingLib.getByTestId('button-container');
|
|
353
|
-
|
|
354
|
-
expect(button).toHaveStyle({
|
|
355
|
-
backgroundColor: light.bg.basic,
|
|
356
|
-
borderBottomColor: light.button.light.bg,
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it('should render [type=outlined] `disabled` button', () => {
|
|
361
|
-
testingLib = render(
|
|
362
|
-
Component({
|
|
363
|
-
props: {
|
|
364
|
-
type: 'outlined',
|
|
365
|
-
disabled: true,
|
|
366
|
-
text: 'my-button',
|
|
367
|
-
},
|
|
368
|
-
}),
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
const button = testingLib.getByTestId('button-container');
|
|
372
|
-
|
|
373
|
-
const text = testingLib.getByText('my-button');
|
|
374
|
-
expect(text).toHaveStyle({color: light.button.disabled.text});
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
describe('Outlined - dark mode', () => {
|
|
379
|
-
it('should render [type=outlined] [color=primary] button', () => {
|
|
380
|
-
testingLib = render(
|
|
381
|
-
Component({
|
|
382
|
-
props: {
|
|
383
|
-
type: 'outlined',
|
|
384
|
-
color: 'primary',
|
|
385
|
-
},
|
|
386
|
-
themeType: 'dark',
|
|
387
|
-
}),
|
|
388
|
-
);
|
|
389
|
-
|
|
390
|
-
const button = testingLib.getByTestId('button-container');
|
|
391
|
-
expect(button).toHaveStyle({borderBottomColor: dark.button.primary.bg});
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
it('should render [type=outlined] [color=secondary] button', () => {
|
|
395
|
-
testingLib = render(
|
|
396
|
-
Component({
|
|
397
|
-
props: {
|
|
398
|
-
type: 'outlined',
|
|
399
|
-
color: 'secondary',
|
|
400
|
-
},
|
|
401
|
-
themeType: 'dark',
|
|
402
|
-
}),
|
|
403
|
-
);
|
|
404
|
-
|
|
405
|
-
const button = testingLib.getByTestId('button-container');
|
|
406
|
-
expect(button).toHaveStyle({
|
|
407
|
-
borderBottomColor: dark.button.secondary.bg,
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
it('should render [type=outlined] [color=success] button', () => {
|
|
412
|
-
testingLib = render(
|
|
413
|
-
Component({
|
|
414
|
-
props: {
|
|
415
|
-
type: 'outlined',
|
|
416
|
-
color: 'success',
|
|
417
|
-
},
|
|
418
|
-
themeType: 'dark',
|
|
419
|
-
}),
|
|
420
|
-
);
|
|
421
|
-
|
|
422
|
-
const button = testingLib.getByTestId('button-container');
|
|
423
|
-
expect(button).toHaveStyle({borderBottomColor: dark.button.success.bg});
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
it('should render [type=outlined] [color=warning] button', () => {
|
|
427
|
-
testingLib = render(
|
|
428
|
-
Component({
|
|
429
|
-
props: {
|
|
430
|
-
type: 'outlined',
|
|
431
|
-
color: 'warning',
|
|
432
|
-
},
|
|
433
|
-
themeType: 'dark',
|
|
434
|
-
}),
|
|
435
|
-
);
|
|
436
|
-
|
|
437
|
-
const button = testingLib.getByTestId('button-container');
|
|
438
|
-
expect(button).toHaveStyle({borderBottomColor: dark.button.warning.bg});
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
it('should render [type=outlined] [color=danger] button', () => {
|
|
442
|
-
testingLib = render(
|
|
443
|
-
Component({
|
|
444
|
-
props: {
|
|
445
|
-
type: 'outlined',
|
|
446
|
-
color: 'danger',
|
|
447
|
-
},
|
|
448
|
-
themeType: 'dark',
|
|
449
|
-
}),
|
|
450
|
-
);
|
|
451
|
-
|
|
452
|
-
const button = testingLib.getByTestId('button-container');
|
|
453
|
-
expect(button).toHaveStyle({borderBottomColor: dark.button.danger.bg});
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
it('should [type=outlined] [color=light] button', () => {
|
|
457
|
-
testingLib = render(
|
|
458
|
-
Component({
|
|
459
|
-
props: {
|
|
460
|
-
type: 'outlined',
|
|
461
|
-
color: 'light',
|
|
462
|
-
},
|
|
463
|
-
themeType: 'dark',
|
|
464
|
-
}),
|
|
465
|
-
);
|
|
466
|
-
|
|
467
|
-
const button = testingLib.getByTestId('button-container');
|
|
468
|
-
expect(button).toHaveStyle({borderBottomColor: dark.button.light.bg});
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
it('should render [type=outlined] [color=info] button', () => {
|
|
472
|
-
testingLib = render(
|
|
473
|
-
Component({
|
|
474
|
-
props: {
|
|
475
|
-
type: 'outlined',
|
|
476
|
-
color: 'info',
|
|
477
|
-
},
|
|
478
|
-
themeType: 'dark',
|
|
479
|
-
}),
|
|
480
|
-
);
|
|
481
|
-
|
|
482
|
-
const button = testingLib.getByTestId('button-container');
|
|
483
|
-
expect(button).toHaveStyle({borderBottomColor: dark.button.info.bg});
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
it('should render [type=outlined] `disabled` button', () => {
|
|
487
|
-
testingLib = render(
|
|
488
|
-
Component({
|
|
489
|
-
props: {
|
|
490
|
-
type: 'outlined',
|
|
491
|
-
disabled: true,
|
|
492
|
-
text: 'my-button',
|
|
493
|
-
},
|
|
494
|
-
themeType: 'dark',
|
|
495
|
-
}),
|
|
496
|
-
);
|
|
497
|
-
|
|
498
|
-
const button = testingLib.getByTestId('button-container');
|
|
499
|
-
|
|
500
|
-
const text = testingLib.getByText('my-button');
|
|
501
|
-
expect(text).toHaveStyle({color: dark.button.disabled.text});
|
|
502
|
-
});
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
describe('[Button] sizes', () => {
|
|
506
|
-
it('should render [large] button', () => {
|
|
507
|
-
testingLib = render(
|
|
508
|
-
Component({
|
|
509
|
-
props: {size: 'large'},
|
|
510
|
-
}),
|
|
511
|
-
);
|
|
512
|
-
|
|
513
|
-
const button = testingLib.getByTestId('button-container');
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
it('should render [small] button', () => {
|
|
517
|
-
testingLib = render(
|
|
518
|
-
Component({
|
|
519
|
-
props: {
|
|
520
|
-
size: 'small',
|
|
521
|
-
color: 'danger',
|
|
522
|
-
},
|
|
523
|
-
themeType: 'dark',
|
|
524
|
-
}),
|
|
525
|
-
);
|
|
526
|
-
|
|
527
|
-
const button = testingLib.getByTestId('button-container');
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
describe('[Button] borderRadius', () => {
|
|
532
|
-
it('should render with given borderRadius', () => {
|
|
533
|
-
const borderRadius = 10;
|
|
534
|
-
|
|
535
|
-
testingLib = render(
|
|
536
|
-
Component({
|
|
537
|
-
props: {
|
|
538
|
-
borderRadius: borderRadius,
|
|
539
|
-
},
|
|
540
|
-
}),
|
|
541
|
-
);
|
|
542
|
-
|
|
543
|
-
const button = testingLib.getByTestId('button-container');
|
|
544
|
-
expect(button).toHaveStyle({borderRadius: borderRadius});
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
describe('[Button] custom theme', () => {
|
|
549
|
-
it('should render with custom primary color from theme', () => {
|
|
550
|
-
const customTheme = {
|
|
551
|
-
light: {
|
|
552
|
-
button: {
|
|
553
|
-
primary: {
|
|
554
|
-
bg: '#FF5733',
|
|
555
|
-
text: '#FFFFFF',
|
|
556
|
-
},
|
|
557
|
-
},
|
|
558
|
-
},
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
testingLib = render(
|
|
562
|
-
<ThemeProvider customTheme={customTheme}>
|
|
563
|
-
<Button color="primary" onPress={jest.fn} testID="custom-button" />
|
|
564
|
-
</ThemeProvider>,
|
|
565
|
-
);
|
|
566
|
-
|
|
567
|
-
const button = testingLib.getByTestId('button-container');
|
|
568
|
-
expect(button).toHaveStyle({backgroundColor: '#FF5733'});
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
it('should render with custom primary color in dark mode', () => {
|
|
572
|
-
const customTheme = {
|
|
573
|
-
dark: {
|
|
574
|
-
button: {
|
|
575
|
-
primary: {
|
|
576
|
-
bg: '#00BFFF',
|
|
577
|
-
text: '#000000',
|
|
578
|
-
},
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
testingLib = render(
|
|
584
|
-
<ThemeProvider initialThemeType="dark" customTheme={customTheme}>
|
|
585
|
-
<Button color="primary" onPress={jest.fn} testID="custom-button" />
|
|
586
|
-
</ThemeProvider>,
|
|
587
|
-
);
|
|
588
|
-
|
|
589
|
-
const button = testingLib.getByTestId('button-container');
|
|
590
|
-
expect(button).toHaveStyle({backgroundColor: '#00BFFF'});
|
|
591
|
-
});
|
|
592
|
-
|
|
593
|
-
it('should render outlined button with custom primary color', () => {
|
|
594
|
-
const customTheme = {
|
|
595
|
-
light: {
|
|
596
|
-
button: {
|
|
597
|
-
primary: {
|
|
598
|
-
bg: '#9C27B0',
|
|
599
|
-
text: '#FFFFFF',
|
|
600
|
-
},
|
|
601
|
-
},
|
|
602
|
-
},
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
testingLib = render(
|
|
606
|
-
<ThemeProvider customTheme={customTheme}>
|
|
607
|
-
<Button
|
|
608
|
-
type="outlined"
|
|
609
|
-
color="primary"
|
|
610
|
-
onPress={jest.fn}
|
|
611
|
-
testID="custom-button"
|
|
612
|
-
/>
|
|
613
|
-
</ThemeProvider>,
|
|
614
|
-
);
|
|
615
|
-
|
|
616
|
-
const button = testingLib.getByTestId('button-container');
|
|
617
|
-
expect(button).toHaveStyle({borderBottomColor: '#9C27B0'});
|
|
618
|
-
});
|
|
619
|
-
});
|
|
620
|
-
});
|