@channel.io/bezier-react 3.1.2 → 3.1.4
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/dist/cjs/components/AlphaAvatar/Avatar.js +0 -2
- package/dist/cjs/components/AlphaAvatar/Avatar.js.map +1 -1
- package/dist/cjs/components/Avatar/Avatar.js +0 -2
- package/dist/cjs/components/Avatar/Avatar.js.map +1 -1
- package/dist/cjs/components/Badge/Badge.js +0 -1
- package/dist/cjs/components/Badge/Badge.js.map +1 -1
- package/dist/cjs/components/Checkbox/Checkbox.js +2 -0
- package/dist/cjs/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/cjs/components/Divider/Divider.js +1 -1
- package/dist/cjs/components/Divider/Divider.js.map +1 -1
- package/dist/cjs/components/Emoji/Emoji.js +0 -1
- package/dist/cjs/components/Emoji/Emoji.js.map +1 -1
- package/dist/cjs/components/FormControl/FormControl.js +0 -1
- package/dist/cjs/components/FormControl/FormControl.js.map +1 -1
- package/dist/cjs/components/FormHelperText/FormHelperText.js +4 -2
- package/dist/cjs/components/FormHelperText/FormHelperText.js.map +1 -1
- package/dist/cjs/components/NavGroup/NavGroup.js +4 -2
- package/dist/cjs/components/NavGroup/NavGroup.js.map +1 -1
- package/dist/cjs/components/NavItem/NavItem.js +4 -2
- package/dist/cjs/components/NavItem/NavItem.js.map +1 -1
- package/dist/cjs/components/SegmentedControl/SegmentedControl.js +10 -3
- package/dist/cjs/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/cjs/components/Switch/Switch.js +0 -1
- package/dist/cjs/components/Switch/Switch.js.map +1 -1
- package/dist/cjs/components/Tag/Tag.js +5 -2
- package/dist/cjs/components/Tag/Tag.js.map +1 -1
- package/dist/cjs/components/TextField/TextField.js +5 -2
- package/dist/cjs/components/TextField/TextField.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/components/AlphaAvatar/Avatar.mjs +1 -1
- package/dist/esm/components/AlphaAvatar/Avatar.mjs.map +1 -1
- package/dist/esm/components/Avatar/Avatar.mjs +1 -1
- package/dist/esm/components/Avatar/Avatar.mjs.map +1 -1
- package/dist/esm/components/Badge/Badge.mjs +1 -1
- package/dist/esm/components/Badge/Badge.mjs.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.mjs +2 -0
- package/dist/esm/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/esm/components/Divider/Divider.mjs +2 -1
- package/dist/esm/components/Divider/Divider.mjs.map +1 -1
- package/dist/esm/components/Emoji/Emoji.mjs +1 -1
- package/dist/esm/components/Emoji/Emoji.mjs.map +1 -1
- package/dist/esm/components/FormControl/FormControl.mjs +1 -1
- package/dist/esm/components/FormControl/FormControl.mjs.map +1 -1
- package/dist/esm/components/FormHelperText/FormHelperText.mjs +5 -1
- package/dist/esm/components/FormHelperText/FormHelperText.mjs.map +1 -1
- package/dist/esm/components/NavGroup/NavGroup.mjs +5 -1
- package/dist/esm/components/NavGroup/NavGroup.mjs.map +1 -1
- package/dist/esm/components/NavItem/NavItem.mjs +5 -1
- package/dist/esm/components/NavItem/NavItem.mjs.map +1 -1
- package/dist/esm/components/SegmentedControl/SegmentedControl.mjs +10 -3
- package/dist/esm/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
- package/dist/esm/components/Switch/Switch.mjs +1 -1
- package/dist/esm/components/Switch/Switch.mjs.map +1 -1
- package/dist/esm/components/Tag/Tag.mjs +6 -1
- package/dist/esm/components/Tag/Tag.mjs.map +1 -1
- package/dist/esm/components/TextField/TextField.mjs +6 -1
- package/dist/esm/components/TextField/TextField.mjs.map +1 -1
- package/dist/esm/styles.css +1 -1
- package/dist/types/components/AlphaAvatar/Avatar.d.ts +0 -2
- package/dist/types/components/AlphaAvatar/Avatar.d.ts.map +1 -1
- package/dist/types/components/Avatar/Avatar.d.ts +0 -2
- package/dist/types/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/types/components/Badge/Badge.d.ts +0 -1
- package/dist/types/components/Badge/Badge.d.ts.map +1 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +2 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/types/components/Divider/Divider.d.ts +0 -1
- package/dist/types/components/Divider/Divider.d.ts.map +1 -1
- package/dist/types/components/Emoji/Emoji.d.ts +0 -1
- package/dist/types/components/Emoji/Emoji.d.ts.map +1 -1
- package/dist/types/components/FormControl/FormControl.d.ts +0 -1
- package/dist/types/components/FormControl/FormControl.d.ts.map +1 -1
- package/dist/types/components/FormHelperText/FormHelperText.d.ts +0 -2
- package/dist/types/components/FormHelperText/FormHelperText.d.ts.map +1 -1
- package/dist/types/components/NavGroup/NavGroup.d.ts +0 -2
- package/dist/types/components/NavGroup/NavGroup.d.ts.map +1 -1
- package/dist/types/components/NavItem/NavItem.d.ts +0 -2
- package/dist/types/components/NavItem/NavItem.d.ts.map +1 -1
- package/dist/types/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/types/components/Switch/Switch.d.ts +0 -1
- package/dist/types/components/Switch/Switch.d.ts.map +1 -1
- package/dist/types/components/Tag/Tag.d.ts +0 -2
- package/dist/types/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/components/TextField/TextField.d.ts +0 -2
- package/dist/types/components/TextField/TextField.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/components/AlphaAvatar/Avatar.test.tsx +1 -71
- package/src/components/AlphaAvatar/Avatar.tsx +2 -2
- package/src/components/AlphaAvatarGroup/AvatarGroup.test.tsx +0 -12
- package/src/components/Avatar/Avatar.test.tsx +1 -71
- package/src/components/Avatar/Avatar.tsx +2 -2
- package/src/components/AvatarGroup/AvatarGroup.test.tsx +0 -12
- package/src/components/Badge/Badge.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +6 -1
- package/src/components/Divider/Divider.test.tsx +11 -12
- package/src/components/Divider/Divider.tsx +5 -1
- package/src/components/Emoji/Emoji.tsx +4 -1
- package/src/components/FormControl/FormControl.test.tsx +1 -39
- package/src/components/FormControl/FormControl.tsx +1 -1
- package/src/components/FormHelperText/FormHelperText.test.tsx +11 -30
- package/src/components/FormHelperText/FormHelperText.tsx +9 -2
- package/src/components/FormLabel/FormLabel.test.tsx +0 -7
- package/src/components/Help/Help.test.tsx +0 -14
- package/src/components/LegacyTooltip/LegacyTooltip.test.tsx +0 -12
- package/src/components/Modal/Modal.test.tsx +8 -1
- package/src/components/NavGroup/NavGroup.tsx +9 -2
- package/src/components/NavItem/NavItem.tsx +9 -2
- package/src/components/SegmentedControl/SegmentedControl.module.scss +1 -1
- package/src/components/SegmentedControl/SegmentedControl.tsx +16 -3
- package/src/components/Slider/Slider.test.tsx +1 -8
- package/src/components/SmoothCornersBox/SmoothCornersBox.test.tsx +0 -5
- package/src/components/Switch/Switch.test.tsx +17 -17
- package/src/components/Switch/Switch.tsx +4 -1
- package/src/components/Tag/Tag.test.tsx +11 -15
- package/src/components/Tag/Tag.tsx +10 -2
- package/src/components/TextField/TextField.test.tsx +5 -5
- package/src/components/TextField/TextField.tsx +10 -2
- package/src/components/AlphaAvatar/__snapshots__/Avatar.test.tsx.snap +0 -93
- package/src/components/AlphaAvatarGroup/__snapshots__/AvatarGroup.test.tsx.snap +0 -215
- package/src/components/Avatar/__snapshots__/Avatar.test.tsx.snap +0 -93
- package/src/components/AvatarGroup/__snapshots__/AvatarGroup.test.tsx.snap +0 -215
- package/src/components/Badge/Badge.test.tsx +0 -27
- package/src/components/Badge/__snapshots__/Badge.test.tsx.snap +0 -8
- package/src/components/Emoji/Emoji.test.tsx +0 -32
- package/src/components/Emoji/__snapshots__/Emoji.test.tsx.snap +0 -11
- package/src/components/FormControl/__snapshots__/FormControl.test.tsx.snap +0 -249
- package/src/components/FormGroup/FormGroup.test.tsx +0 -24
- package/src/components/FormGroup/__snapshots__/FormGroup.test.tsx.snap +0 -10
- package/src/components/FormHelperText/__snapshots__/FormHelperText.test.tsx.snap +0 -24
- package/src/components/FormLabel/__snapshots__/FormLabel.test.tsx.snap +0 -11
- package/src/components/Help/__snapshots__/Help.test.tsx.snap +0 -21
- package/src/components/LegacyTooltip/__snapshots__/LegacyTooltip.test.tsx.snap +0 -37
- package/src/components/NavGroup/NavGroup.test.tsx +0 -75
- package/src/components/NavGroup/__snapshots__/NavGroup.test.tsx.snap +0 -121
- package/src/components/NavItem/NavItem.test.tsx +0 -66
- package/src/components/NavItem/__snapshots__/NavItem.test.tsx.snap +0 -75
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +0 -50
- package/src/components/SmoothCornersBox/__snapshots__/SmoothCornersBox.test.tsx.snap +0 -11
- package/src/components/Tag/__snapshots__/Tag.test.tsx.snap +0 -8
|
@@ -2,7 +2,7 @@ import { isInaccessible } from '@testing-library/react'
|
|
|
2
2
|
|
|
3
3
|
import { render } from '~/src/utils/test'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { FormControl } from './FormControl'
|
|
6
6
|
import { type FormControlProps } from './FormControl.types'
|
|
7
7
|
import {
|
|
8
8
|
MOCK_CONSTS,
|
|
@@ -34,44 +34,6 @@ describe('FormControl >', () => {
|
|
|
34
34
|
</FormControl>
|
|
35
35
|
)
|
|
36
36
|
|
|
37
|
-
describe('Snapshot >', () => {
|
|
38
|
-
it('With single field', () => {
|
|
39
|
-
const { getByTestId } = renderComponent({
|
|
40
|
-
children: SingleFieldForm,
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
const rendered = getByTestId(FORM_CONTROL_TEST_ID)
|
|
44
|
-
expect(rendered).toMatchSnapshot()
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('With single field and left label position', () => {
|
|
48
|
-
const { getByTestId } = renderComponent({
|
|
49
|
-
labelPosition: 'left',
|
|
50
|
-
children: SingleFieldForm,
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const rendered = getByTestId(FORM_CONTROL_TEST_ID)
|
|
54
|
-
expect(rendered).toMatchSnapshot()
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
it('With multiple field', () => {
|
|
58
|
-
const { container } = renderComponent({
|
|
59
|
-
children: MultipleFieldForm,
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
expect(container).toMatchSnapshot()
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('With multiple field and left label position', () => {
|
|
66
|
-
const { container } = renderComponent({
|
|
67
|
-
labelPosition: 'left',
|
|
68
|
-
children: MultipleFieldForm,
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
expect(container).toMatchSnapshot()
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
|
|
75
37
|
describe('Accessibility >', () => {
|
|
76
38
|
it('With single field', () => {
|
|
77
39
|
const { container } = renderComponent({
|
|
@@ -36,7 +36,7 @@ const [FormControlContextProvider, useFormControlContext] = createContext<
|
|
|
36
36
|
|
|
37
37
|
export { useFormControlContext }
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
const FORM_CONTROL_TEST_ID = 'bezier-form-control'
|
|
40
40
|
|
|
41
41
|
const Container = forwardRef<HTMLElement, ContainerProps>(function Container(
|
|
42
42
|
{ labelPosition, children, className, ...rest },
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { render } from '~/src/utils/test'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
FORM_ERROR_MESSAGE_TEST_ID,
|
|
5
|
-
FORM_HELPER_TEXT_TEST_ID,
|
|
6
|
-
FormErrorMessage,
|
|
7
|
-
FormHelperText,
|
|
8
|
-
} from './FormHelperText'
|
|
3
|
+
import { FormErrorMessage, FormHelperText } from './FormHelperText'
|
|
9
4
|
import type {
|
|
10
5
|
FormErrorMessageProps,
|
|
11
6
|
FormHelperTextProps,
|
|
@@ -30,23 +25,16 @@ describe('FormHelperText >', () => {
|
|
|
30
25
|
/>
|
|
31
26
|
)
|
|
32
27
|
|
|
33
|
-
it('Snapshot >', () => {
|
|
34
|
-
const { getByTestId } = renderFormHelperText()
|
|
35
|
-
const helperText = getByTestId(FORM_HELPER_TEXT_TEST_ID)
|
|
36
|
-
|
|
37
|
-
expect(helperText).toMatchSnapshot()
|
|
38
|
-
})
|
|
39
|
-
|
|
40
28
|
it('renders text when children prop is not empty', () => {
|
|
41
|
-
const {
|
|
42
|
-
const helperText =
|
|
29
|
+
const { getByText } = renderFormHelperText()
|
|
30
|
+
const helperText = getByText(text)
|
|
43
31
|
|
|
44
32
|
expect(helperText).toBeInTheDocument()
|
|
45
33
|
})
|
|
46
34
|
|
|
47
35
|
it('renders nothing when children prop is empty', () => {
|
|
48
|
-
const {
|
|
49
|
-
const helperText =
|
|
36
|
+
const { queryByText } = renderFormHelperText({ children: '' })
|
|
37
|
+
const helperText = queryByText(text)
|
|
50
38
|
|
|
51
39
|
expect(helperText).toBeNull()
|
|
52
40
|
})
|
|
@@ -71,30 +59,23 @@ describe('FormErrorMessage >', () => {
|
|
|
71
59
|
/>
|
|
72
60
|
)
|
|
73
61
|
|
|
74
|
-
it('Snapshot >', () => {
|
|
75
|
-
const { getByTestId } = renderFormHelperText()
|
|
76
|
-
const rendered = getByTestId(FORM_ERROR_MESSAGE_TEST_ID)
|
|
77
|
-
|
|
78
|
-
expect(rendered).toMatchSnapshot()
|
|
79
|
-
})
|
|
80
|
-
|
|
81
62
|
it('renders text when children prop is not empty', () => {
|
|
82
|
-
const {
|
|
83
|
-
const rendered =
|
|
63
|
+
const { getByText } = renderFormHelperText()
|
|
64
|
+
const rendered = getByText(text)
|
|
84
65
|
|
|
85
66
|
expect(rendered).toBeInTheDocument()
|
|
86
67
|
})
|
|
87
68
|
|
|
88
69
|
it('renders nothing when children prop is empty', () => {
|
|
89
|
-
const {
|
|
90
|
-
const rendered =
|
|
70
|
+
const { queryByText } = renderFormHelperText({ children: '' })
|
|
71
|
+
const rendered = queryByText(text)
|
|
91
72
|
|
|
92
73
|
expect(rendered).toBeNull()
|
|
93
74
|
})
|
|
94
75
|
|
|
95
76
|
it('should have aria-live="polite" attribute', () => {
|
|
96
|
-
const {
|
|
97
|
-
const rendered =
|
|
77
|
+
const { getByText } = renderFormHelperText()
|
|
78
|
+
const rendered = getByText(text)
|
|
98
79
|
|
|
99
80
|
expect(rendered).toHaveAttribute('aria-live', 'polite')
|
|
100
81
|
})
|
|
@@ -19,8 +19,15 @@ import type {
|
|
|
19
19
|
|
|
20
20
|
import styles from './FormHelperText.module.scss'
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated
|
|
24
|
+
*/
|
|
25
|
+
const FORM_HELPER_TEXT_TEST_ID = 'bezier-form-helper-text'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated
|
|
29
|
+
*/
|
|
30
|
+
const FORM_ERROR_MESSAGE_TEST_ID = 'bezier-form-error-message'
|
|
24
31
|
|
|
25
32
|
const BaseHelperText = forwardRef<HTMLSpanElement, BaseHelperTextProps>(
|
|
26
33
|
function BaseHelperText(props, forwardedRef) {
|
|
@@ -23,13 +23,6 @@ describe('FormLabel >', () => {
|
|
|
23
23
|
/>
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
-
it('Snapshot >', () => {
|
|
27
|
-
const { getByTestId } = renderComponent()
|
|
28
|
-
const rendered = getByTestId(FORM_LABEL_TEST_ID)
|
|
29
|
-
|
|
30
|
-
expect(rendered).toMatchSnapshot()
|
|
31
|
-
})
|
|
32
|
-
|
|
33
26
|
it('renders text when children prop is not empty', () => {
|
|
34
27
|
const { getByTestId } = renderComponent()
|
|
35
28
|
const rendered = getByTestId(FORM_LABEL_TEST_ID)
|
|
@@ -20,20 +20,6 @@ describe('Help >', () => {
|
|
|
20
20
|
/>
|
|
21
21
|
)
|
|
22
22
|
|
|
23
|
-
it('Snapshot >', () => {
|
|
24
|
-
const { getByTestId } = renderComponent()
|
|
25
|
-
const rendered = getByTestId(HELP_TEST_ID)
|
|
26
|
-
|
|
27
|
-
expect(rendered).toMatchSnapshot()
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('renders text when children prop is not empty', () => {
|
|
31
|
-
const { getByTestId } = renderComponent()
|
|
32
|
-
const rendered = getByTestId(HELP_TEST_ID)
|
|
33
|
-
|
|
34
|
-
expect(rendered).toBeInTheDocument()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
23
|
it('renders nothing when children prop is empty', () => {
|
|
38
24
|
const { queryByTestId } = renderComponent({ children: '' })
|
|
39
25
|
const rendered = queryByTestId(HELP_TEST_ID)
|
|
@@ -42,18 +42,6 @@ describe('Tooltip test >', () => {
|
|
|
42
42
|
/>
|
|
43
43
|
)
|
|
44
44
|
|
|
45
|
-
it('Tooltip with default props', () => {
|
|
46
|
-
const { baseElement, getByTestId } = renderTooltip()
|
|
47
|
-
|
|
48
|
-
act(() => {
|
|
49
|
-
fireEvent.mouseOver(getByTestId(TOOLTIP_TEST_ID))
|
|
50
|
-
|
|
51
|
-
jest.runAllTimers()
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
expect(baseElement).toMatchSnapshot()
|
|
55
|
-
})
|
|
56
|
-
|
|
57
45
|
it('TooltipContent not rendered at first', async () => {
|
|
58
46
|
const { queryByTestId } = renderTooltip()
|
|
59
47
|
|
|
@@ -157,6 +157,7 @@ describe('Modal', () => {
|
|
|
157
157
|
it("should have proper 'aria-labelledby' attribute (only title)", () => {
|
|
158
158
|
const { getByRole } = renderOpenedModal({
|
|
159
159
|
modalHeaderProps: { title: TITLE_TEXT, subtitle: null },
|
|
160
|
+
modalContentProps: { 'aria-describedby': undefined },
|
|
160
161
|
})
|
|
161
162
|
expect(getByRole('dialog', { name: TITLE_TEXT })).toBeInTheDocument()
|
|
162
163
|
})
|
|
@@ -164,6 +165,7 @@ describe('Modal', () => {
|
|
|
164
165
|
it("should have proper 'aria-labelledby' attribute (hidden title)", () => {
|
|
165
166
|
const { getByRole } = renderOpenedModal({
|
|
166
167
|
modalHeaderProps: { title: TITLE_TEXT, subtitle: null, hidden: true },
|
|
168
|
+
modalContentProps: { 'aria-describedby': undefined },
|
|
167
169
|
})
|
|
168
170
|
expect(getByRole('dialog', { name: TITLE_TEXT })).toBeInTheDocument()
|
|
169
171
|
})
|
|
@@ -248,6 +250,7 @@ describe('Modal', () => {
|
|
|
248
250
|
|
|
249
251
|
it("should be visually hidden when the 'hidden' prop is true", () => {
|
|
250
252
|
const { queryByRole } = renderOpenedModal({
|
|
253
|
+
modalContentProps: { 'aria-describedby': undefined },
|
|
251
254
|
modalHeaderProps: { title: TITLE_TEXT, hidden: true },
|
|
252
255
|
})
|
|
253
256
|
/**
|
|
@@ -330,7 +333,11 @@ describe('Modal', () => {
|
|
|
330
333
|
<ModalTrigger>
|
|
331
334
|
<button type="button">{TRIGGER_TEXT}</button>
|
|
332
335
|
</ModalTrigger>
|
|
333
|
-
<ModalContent>
|
|
336
|
+
<ModalContent aria-describedby={undefined}>
|
|
337
|
+
<ModalHeader
|
|
338
|
+
hidden
|
|
339
|
+
title={TITLE_TEXT}
|
|
340
|
+
/>
|
|
334
341
|
<ModalBody>
|
|
335
342
|
<input type="text" />
|
|
336
343
|
</ModalBody>
|
|
@@ -21,8 +21,15 @@ import type { NavGroupProps } from './NavGroup.types'
|
|
|
21
21
|
|
|
22
22
|
import styles from './NavGroup.module.scss'
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated
|
|
26
|
+
*/
|
|
27
|
+
const NAV_GROUP_TEST_ID = 'bezier-nav-group'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated
|
|
31
|
+
*/
|
|
32
|
+
const NAV_GROUP_LEFT_ICON_TEST_ID = 'bezier-nav-group-left-icon'
|
|
26
33
|
|
|
27
34
|
export const NavGroup = forwardRef<HTMLButtonElement, NavGroupProps>(
|
|
28
35
|
function NavGroup(
|
|
@@ -11,8 +11,15 @@ import type { NavItemProps } from './NavItem.types'
|
|
|
11
11
|
|
|
12
12
|
import styles from './NavItem.module.scss'
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated
|
|
16
|
+
*/
|
|
17
|
+
const NAV_ITEM_TEST_ID = 'bezier-nav-item'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated
|
|
21
|
+
*/
|
|
22
|
+
const NAV_ITEM_LEFT_ICON_TEST_ID = 'bezier-nav-item-left-icon'
|
|
16
23
|
|
|
17
24
|
/**
|
|
18
25
|
* `NavItem` is a component for an item where you can navigate to another link.
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
type SegmentedControlItemProps,
|
|
32
32
|
type SegmentedControlProps,
|
|
33
33
|
type SegmentedControlRadioGroupProps,
|
|
34
|
+
type SegmentedControlSize,
|
|
34
35
|
type SegmentedControlTabContentProps,
|
|
35
36
|
type SegmentedControlTabListProps,
|
|
36
37
|
type SegmentedControlTabsProps,
|
|
@@ -289,6 +290,17 @@ type ItemProps<Type extends SegmentedControlType> = (Type extends 'radiogroup'
|
|
|
289
290
|
React.HTMLAttributes<HTMLButtonElement> &
|
|
290
291
|
Partial<SegmentedControlItemProps<Type>>
|
|
291
292
|
|
|
293
|
+
function getTypography(size: SegmentedControlSize) {
|
|
294
|
+
return (
|
|
295
|
+
{
|
|
296
|
+
xs: '13',
|
|
297
|
+
s: '13',
|
|
298
|
+
m: '13',
|
|
299
|
+
l: '14',
|
|
300
|
+
} as const
|
|
301
|
+
)[size]
|
|
302
|
+
}
|
|
303
|
+
|
|
292
304
|
const Item = forwardRef<HTMLButtonElement, ItemProps<SegmentedControlType>>(
|
|
293
305
|
function Item(
|
|
294
306
|
{ children, leftContent, rightContent, className, ...rest },
|
|
@@ -324,17 +336,18 @@ const Item = forwardRef<HTMLButtonElement, ItemProps<SegmentedControlType>>(
|
|
|
324
336
|
<HStack
|
|
325
337
|
className={styles.SegmentedControlItemContainer}
|
|
326
338
|
align="center"
|
|
327
|
-
spacing={
|
|
339
|
+
spacing={4}
|
|
328
340
|
>
|
|
329
341
|
{leftContent}
|
|
342
|
+
|
|
330
343
|
<Text
|
|
331
344
|
className={styles.SegmentedControlItemLabel}
|
|
332
345
|
bold
|
|
333
|
-
|
|
334
|
-
typo={size === 'xs' ? '13' : '14'}
|
|
346
|
+
typo={getTypography(size)}
|
|
335
347
|
>
|
|
336
348
|
{children}
|
|
337
349
|
</Text>
|
|
350
|
+
|
|
338
351
|
{rightContent}
|
|
339
352
|
</HStack>
|
|
340
353
|
</BaseButton>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isInaccessible
|
|
1
|
+
import { isInaccessible } from '@testing-library/react'
|
|
2
2
|
import userEvent from '@testing-library/user-event'
|
|
3
3
|
|
|
4
4
|
import { render } from '~/src/utils/test'
|
|
@@ -16,13 +16,6 @@ describe('Slider', () => {
|
|
|
16
16
|
user = userEvent.setup()
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
describe('Snapshot', () => {
|
|
20
|
-
it('should match snapshot', () => {
|
|
21
|
-
const { container } = renderSlider({ defaultValue: [5], guide: [5] })
|
|
22
|
-
expect(container).toMatchSnapshot()
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
19
|
describe('ARIA', () => {
|
|
27
20
|
it('should be accessible', () => {
|
|
28
21
|
const { container } = renderSlider()
|
|
@@ -9,11 +9,6 @@ describe('SmoothCornersBox', () => {
|
|
|
9
9
|
) => render(<SmoothCornersBox {...rest}>{children}</SmoothCornersBox>)
|
|
10
10
|
|
|
11
11
|
describe('Style', () => {
|
|
12
|
-
it('snapshot with default value', () => {
|
|
13
|
-
const { container } = renderSmoothCornersBox()
|
|
14
|
-
expect(container).toMatchSnapshot()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
12
|
it('each style property must have the correct unit.', () => {
|
|
18
13
|
const children = 'foo'
|
|
19
14
|
const { getByText } = renderSmoothCornersBox({
|
|
@@ -2,7 +2,7 @@ import userEvent from '@testing-library/user-event'
|
|
|
2
2
|
|
|
3
3
|
import { render } from '~/src/utils/test'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Switch } from './Switch'
|
|
6
6
|
import { type SwitchProps } from './Switch.types'
|
|
7
7
|
|
|
8
8
|
describe('Switch', () => {
|
|
@@ -12,19 +12,19 @@ describe('Switch', () => {
|
|
|
12
12
|
describe('data attribute', () => {
|
|
13
13
|
describe('data-state', () => {
|
|
14
14
|
it('should have data-state="checked" attribute when checked is true', () => {
|
|
15
|
-
const {
|
|
15
|
+
const { getByRole } = renderComponent({
|
|
16
16
|
checked: true,
|
|
17
17
|
})
|
|
18
|
-
const switchComponent =
|
|
18
|
+
const switchComponent = getByRole('switch')
|
|
19
19
|
|
|
20
20
|
expect(switchComponent).toHaveAttribute('data-state', 'checked')
|
|
21
21
|
})
|
|
22
22
|
|
|
23
23
|
it('should have data-state="unchecked" attribute when checked is false', () => {
|
|
24
|
-
const {
|
|
24
|
+
const { getByRole } = renderComponent({
|
|
25
25
|
checked: false,
|
|
26
26
|
})
|
|
27
|
-
const switchComponent =
|
|
27
|
+
const switchComponent = getByRole('switch')
|
|
28
28
|
|
|
29
29
|
expect(switchComponent).toHaveAttribute('data-state', 'unchecked')
|
|
30
30
|
})
|
|
@@ -32,19 +32,19 @@ describe('Switch', () => {
|
|
|
32
32
|
|
|
33
33
|
describe('data-disabled', () => {
|
|
34
34
|
it('should have data-disabled attribute when disabled is true', () => {
|
|
35
|
-
const {
|
|
35
|
+
const { getByRole } = renderComponent({
|
|
36
36
|
disabled: true,
|
|
37
37
|
})
|
|
38
|
-
const switchComponent =
|
|
38
|
+
const switchComponent = getByRole('switch')
|
|
39
39
|
|
|
40
40
|
expect(switchComponent).toHaveAttribute('data-disabled')
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
it('should not have data-disabled attribute when disabled is false', () => {
|
|
44
|
-
const {
|
|
44
|
+
const { getByRole } = renderComponent({
|
|
45
45
|
disabled: false,
|
|
46
46
|
})
|
|
47
|
-
const switchComponent =
|
|
47
|
+
const switchComponent = getByRole('switch')
|
|
48
48
|
|
|
49
49
|
expect(switchComponent).not.toHaveAttribute('data-disabled')
|
|
50
50
|
})
|
|
@@ -56,12 +56,12 @@ describe('Switch', () => {
|
|
|
56
56
|
const user = userEvent.setup()
|
|
57
57
|
const onClick = jest.fn()
|
|
58
58
|
const onCheckedChange = jest.fn()
|
|
59
|
-
const {
|
|
59
|
+
const { getByRole } = renderComponent({
|
|
60
60
|
defaultChecked: false,
|
|
61
61
|
onClick,
|
|
62
62
|
onCheckedChange,
|
|
63
63
|
})
|
|
64
|
-
const switchComponent =
|
|
64
|
+
const switchComponent = getByRole('switch')
|
|
65
65
|
|
|
66
66
|
await user.click(switchComponent)
|
|
67
67
|
expect(switchComponent).toHaveAttribute('data-state', 'checked')
|
|
@@ -76,11 +76,11 @@ describe('Switch', () => {
|
|
|
76
76
|
it('should change state when user enters Space key on Switch', async () => {
|
|
77
77
|
const user = userEvent.setup()
|
|
78
78
|
const onCheckedChange = jest.fn()
|
|
79
|
-
const {
|
|
79
|
+
const { getByRole } = renderComponent({
|
|
80
80
|
defaultChecked: false,
|
|
81
81
|
onCheckedChange,
|
|
82
82
|
})
|
|
83
|
-
const switchComponent =
|
|
83
|
+
const switchComponent = getByRole('switch')
|
|
84
84
|
|
|
85
85
|
await user.tab()
|
|
86
86
|
await user.keyboard('[Space]')
|
|
@@ -94,11 +94,11 @@ describe('Switch', () => {
|
|
|
94
94
|
it('should change state when user enters Enter key on Switch', async () => {
|
|
95
95
|
const user = userEvent.setup()
|
|
96
96
|
const onCheckedChange = jest.fn()
|
|
97
|
-
const {
|
|
97
|
+
const { getByRole } = renderComponent({
|
|
98
98
|
defaultChecked: false,
|
|
99
99
|
onCheckedChange,
|
|
100
100
|
})
|
|
101
|
-
const switchComponent =
|
|
101
|
+
const switchComponent = getByRole('switch')
|
|
102
102
|
|
|
103
103
|
await user.tab()
|
|
104
104
|
await user.keyboard('[Enter]')
|
|
@@ -113,13 +113,13 @@ describe('Switch', () => {
|
|
|
113
113
|
const user = userEvent.setup()
|
|
114
114
|
const onClick = jest.fn()
|
|
115
115
|
const onCheckedChange = jest.fn()
|
|
116
|
-
const {
|
|
116
|
+
const { getByRole } = renderComponent({
|
|
117
117
|
defaultChecked: false,
|
|
118
118
|
disabled: true,
|
|
119
119
|
onClick,
|
|
120
120
|
onCheckedChange,
|
|
121
121
|
})
|
|
122
|
-
const switchComponent =
|
|
122
|
+
const switchComponent = getByRole('switch')
|
|
123
123
|
|
|
124
124
|
await user.click(switchComponent)
|
|
125
125
|
expect(switchComponent).toHaveAttribute('data-state', 'unchecked')
|
|
@@ -12,7 +12,10 @@ import { type SwitchProps } from './Switch.types'
|
|
|
12
12
|
|
|
13
13
|
import styles from './Switch.module.scss'
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
18
|
+
const SWITCH_TEST_ID = 'bezier-switch'
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* `Switch` is an input component where user can toggle checked state of the element.
|
|
@@ -2,7 +2,7 @@ import userEvent from '@testing-library/user-event'
|
|
|
2
2
|
|
|
3
3
|
import { render } from '~/src/utils/test'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Tag } from './Tag'
|
|
6
6
|
import { type TagProps } from './Tag.types'
|
|
7
7
|
|
|
8
8
|
describe('Tag test >', () => {
|
|
@@ -12,28 +12,24 @@ describe('Tag test >', () => {
|
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
props = {}
|
|
14
14
|
})
|
|
15
|
+
const text = 'test'
|
|
15
16
|
|
|
16
17
|
const renderTag = (optionProps?: TagProps) =>
|
|
17
18
|
render(
|
|
18
19
|
<Tag
|
|
19
20
|
{...props}
|
|
20
21
|
{...optionProps}
|
|
21
|
-
|
|
22
|
+
>
|
|
23
|
+
{text}
|
|
24
|
+
</Tag>
|
|
22
25
|
)
|
|
23
26
|
|
|
24
|
-
it('Snapshot >', () => {
|
|
25
|
-
const { getByTestId } = renderTag()
|
|
26
|
-
const tag = getByTestId(TAG_TEST_ID)
|
|
27
|
-
|
|
28
|
-
expect(tag).toMatchSnapshot()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
27
|
describe('Click Event Test >', () => {
|
|
32
28
|
it('onClick function should be called when the tag is clicked', async () => {
|
|
33
29
|
const onClickFn = jest.fn()
|
|
34
|
-
const {
|
|
30
|
+
const { getByText } = renderTag({ onClick: onClickFn })
|
|
35
31
|
|
|
36
|
-
await user.click(
|
|
32
|
+
await user.click(getByText(text))
|
|
37
33
|
|
|
38
34
|
expect(onClickFn).toHaveBeenCalled()
|
|
39
35
|
})
|
|
@@ -41,12 +37,12 @@ describe('Tag test >', () => {
|
|
|
41
37
|
it('onDelete function should be called when the delete icon is clicked', async () => {
|
|
42
38
|
const onClickFn = jest.fn()
|
|
43
39
|
const onDeleteFn = jest.fn()
|
|
44
|
-
const {
|
|
40
|
+
const { getByLabelText } = renderTag({
|
|
45
41
|
onClick: onClickFn,
|
|
46
42
|
onDelete: onDeleteFn,
|
|
47
43
|
})
|
|
48
44
|
|
|
49
|
-
await user.click(
|
|
45
|
+
await user.click(getByLabelText('delete'))
|
|
50
46
|
|
|
51
47
|
expect(onDeleteFn).toHaveBeenCalled()
|
|
52
48
|
})
|
|
@@ -54,12 +50,12 @@ describe('Tag test >', () => {
|
|
|
54
50
|
it('onClick function should not be called when the delete icon is clicked', async () => {
|
|
55
51
|
const onClickFn = jest.fn()
|
|
56
52
|
const onDeleteFn = jest.fn()
|
|
57
|
-
const {
|
|
53
|
+
const { getByLabelText } = renderTag({
|
|
58
54
|
onClick: onClickFn,
|
|
59
55
|
onDelete: onDeleteFn,
|
|
60
56
|
})
|
|
61
57
|
|
|
62
|
-
await user.click(
|
|
58
|
+
await user.click(getByLabelText('delete'))
|
|
63
59
|
|
|
64
60
|
expect(onClickFn).not.toHaveBeenCalled()
|
|
65
61
|
})
|
|
@@ -13,8 +13,15 @@ import { type TagProps } from './Tag.types'
|
|
|
13
13
|
|
|
14
14
|
import styles from './Tag.module.scss'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
19
|
+
const TAG_TEST_ID = 'bezier-tag'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated
|
|
23
|
+
*/
|
|
24
|
+
const TAG_DELETE_TEST_ID = 'bezier-tag-delete-icon'
|
|
18
25
|
|
|
19
26
|
/**
|
|
20
27
|
* `Tag` is a component for representing tag, which shows close icon when `onDelete` property is specified.
|
|
@@ -55,6 +62,7 @@ export const Tag = memo(
|
|
|
55
62
|
{!isNil(onDelete) && (
|
|
56
63
|
<Icon
|
|
57
64
|
role="button"
|
|
65
|
+
aria-label="delete"
|
|
58
66
|
tabIndex={0}
|
|
59
67
|
className={styles.TagDeleteIcon}
|
|
60
68
|
source={CancelSmallIcon}
|
|
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event'
|
|
|
4
4
|
import { COMMON_IME_CONTROL_KEYS } from '~/src/hooks/useKeyboardActionLockerWhileComposing'
|
|
5
5
|
import { render } from '~/src/utils/test'
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { TextField } from './TextField'
|
|
8
8
|
import { type TextFieldProps } from './TextField.types'
|
|
9
9
|
|
|
10
10
|
describe('TextField', () => {
|
|
@@ -211,7 +211,7 @@ describe('TextField', () => {
|
|
|
211
211
|
// })
|
|
212
212
|
|
|
213
213
|
it('appear when filled & hovered', async () => {
|
|
214
|
-
const { getByRole,
|
|
214
|
+
const { getByRole, getByLabelText } = renderComponent({
|
|
215
215
|
value: 'test',
|
|
216
216
|
allowClear: true,
|
|
217
217
|
})
|
|
@@ -219,12 +219,12 @@ describe('TextField', () => {
|
|
|
219
219
|
|
|
220
220
|
await user.hover(input)
|
|
221
221
|
|
|
222
|
-
const clearButton =
|
|
222
|
+
const clearButton = getByLabelText('Clear input')
|
|
223
223
|
expect(clearButton).toBeVisible()
|
|
224
224
|
})
|
|
225
225
|
|
|
226
226
|
it('appear when filled & focused', () => {
|
|
227
|
-
const { getByRole,
|
|
227
|
+
const { getByRole, getByLabelText } = renderComponent({
|
|
228
228
|
value: 'test',
|
|
229
229
|
allowClear: true,
|
|
230
230
|
})
|
|
@@ -232,7 +232,7 @@ describe('TextField', () => {
|
|
|
232
232
|
|
|
233
233
|
input.focus()
|
|
234
234
|
|
|
235
|
-
const clearButton =
|
|
235
|
+
const clearButton = getByLabelText('Clear input')
|
|
236
236
|
expect(clearButton).toBeVisible()
|
|
237
237
|
})
|
|
238
238
|
|