@channel.io/bezier-react 3.1.1 → 3.1.3
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/SegmentedControl/SegmentedControl.js +10 -3
- package/dist/cjs/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/cjs/packages/bezier-tokens/dist/alpha/esm/darkTheme.js +9 -9
- package/dist/cjs/packages/bezier-tokens/dist/alpha/esm/darkTheme.js.map +1 -1
- package/dist/cjs/packages/bezier-tokens/dist/alpha/esm/global.js +3 -0
- package/dist/cjs/packages/bezier-tokens/dist/alpha/esm/global.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/components/SegmentedControl/SegmentedControl.mjs +10 -3
- package/dist/esm/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
- package/dist/esm/packages/bezier-tokens/dist/alpha/esm/darkTheme.mjs +9 -9
- package/dist/esm/packages/bezier-tokens/dist/alpha/esm/darkTheme.mjs.map +1 -1
- package/dist/esm/packages/bezier-tokens/dist/alpha/esm/global.mjs +3 -0
- package/dist/esm/packages/bezier-tokens/dist/alpha/esm/global.mjs.map +1 -1
- package/dist/esm/styles.css +1 -1
- package/dist/types/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/SegmentedControl/SegmentedControl.module.scss +1 -1
- package/src/components/SegmentedControl/SegmentedControl.tsx +16 -3
- package/src/components/TextArea/TextArea.test.tsx +6 -14
- package/src/components/TextField/TextField.test.tsx +72 -133
- package/src/components/Toast/Toast.test.tsx +1 -1
- package/src/components/Toast/useToastContextValues.test.tsx +27 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../../src/components/SegmentedControl/SegmentedControl.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,GAAG,EAKT,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAkB9B,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../../src/components/SegmentedControl/SegmentedControl.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,GAAG,EAKT,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAkB9B,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAG1B,KAAK,+BAA+B,EACpC,KAAK,4BAA4B,EAEjC,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAA;AA6IjC;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAA+B,CACjE,KAAK,EAAE,4BAA4B,GAAG;IACpC,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;CACzC,KACE,GAAG,CAAC,OAAO,CAAA;AAEhB;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAA4B,CACjE,KAAK,SAAS,MAAM,EAEpB,KAAK,EAAE,+BAA+B,CAAC,KAAK,CAAC,GAAG;IAC9C,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;CACzC,KACE,GAAG,CAAC,OAAO,CAAA;AA+ChB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,gBAAgB,EAAuC,CAClE,IAAI,SAAS,oBAAoB,EACjC,KAAK,SAAS,MAAM,EAEpB,KAAK,EAAE,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG;IAC1C,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;CACzC,KACE,GAAG,CAAC,OAAO,CAAA;AAgGhB;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAA2C,CAC1E,KAAK,SAAS,MAAM,EAEpB,KAAK,EAAE,yBAAyB,CAAC,KAAK,CAAC,GAAG;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAA;CAC5C,KACE,GAAG,CAAC,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@channel.io/bezier-react",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "React components library that implements Bezier design system.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@babel/preset-env": "^7.26.0",
|
|
65
65
|
"@babel/preset-react": "^7.26.3",
|
|
66
66
|
"@babel/preset-typescript": "^7.26.0",
|
|
67
|
-
"@channel.io/bezier-icons": "0.
|
|
67
|
+
"@channel.io/bezier-icons": "0.43.0",
|
|
68
68
|
"@chromatic-com/storybook": "^3.2.2",
|
|
69
69
|
"@figma/code-connect": "^1.2.4",
|
|
70
70
|
"@rollup/plugin-alias": "^5.1.1",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
|
-
"@channel.io/bezier-tokens": "0.3.
|
|
135
|
+
"@channel.io/bezier-tokens": "0.3.1",
|
|
136
136
|
"@radix-ui/react-checkbox": "^1.1.3",
|
|
137
137
|
"@radix-ui/react-dialog": "^1.1.3",
|
|
138
138
|
"@radix-ui/react-radio-group": "^1.2.2",
|
|
@@ -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,5 +1,4 @@
|
|
|
1
1
|
import { fireEvent } from '@testing-library/dom'
|
|
2
|
-
import { act } from '@testing-library/react'
|
|
3
2
|
|
|
4
3
|
import { COMMON_IME_CONTROL_KEYS } from '~/src/hooks/useKeyboardActionLockerWhileComposing'
|
|
5
4
|
import { render } from '~/src/utils/test'
|
|
@@ -54,9 +53,7 @@ describe('TextArea', () => {
|
|
|
54
53
|
const onFocus = jest.fn()
|
|
55
54
|
const { getByRole } = renderComponent({ onFocus, disabled: true })
|
|
56
55
|
const rendered = getByRole('textbox')
|
|
57
|
-
|
|
58
|
-
rendered.focus()
|
|
59
|
-
})
|
|
56
|
+
rendered.focus()
|
|
60
57
|
|
|
61
58
|
expect(onFocus).not.toHaveBeenCalled()
|
|
62
59
|
})
|
|
@@ -65,9 +62,7 @@ describe('TextArea', () => {
|
|
|
65
62
|
const onFocus = jest.fn()
|
|
66
63
|
const { getByRole } = renderComponent({ onFocus })
|
|
67
64
|
const rendered = getByRole('textbox')
|
|
68
|
-
|
|
69
|
-
rendered.focus()
|
|
70
|
-
})
|
|
65
|
+
rendered.focus()
|
|
71
66
|
|
|
72
67
|
expect(onFocus).toHaveBeenCalled()
|
|
73
68
|
})
|
|
@@ -79,9 +74,7 @@ describe('TextArea', () => {
|
|
|
79
74
|
const { getByRole } = renderComponent({ onChange })
|
|
80
75
|
const rendered = getByRole('textbox')
|
|
81
76
|
|
|
82
|
-
|
|
83
|
-
fireEvent.change(rendered, { target: { value: 'test' } })
|
|
84
|
-
})
|
|
77
|
+
fireEvent.change(rendered, { target: { value: 'test' } })
|
|
85
78
|
|
|
86
79
|
expect(onChange).toHaveBeenCalled()
|
|
87
80
|
})
|
|
@@ -92,10 +85,9 @@ describe('TextArea', () => {
|
|
|
92
85
|
const onBlur = jest.fn()
|
|
93
86
|
const { getByRole } = renderComponent({ onBlur })
|
|
94
87
|
const rendered = getByRole('textbox')
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
})
|
|
88
|
+
rendered.focus()
|
|
89
|
+
rendered.blur()
|
|
90
|
+
|
|
99
91
|
expect(onBlur).toHaveBeenCalled()
|
|
100
92
|
})
|
|
101
93
|
})
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { fireEvent } from '@testing-library/dom'
|
|
2
|
-
import { act, within } from '@testing-library/react'
|
|
3
2
|
import userEvent from '@testing-library/user-event'
|
|
4
3
|
|
|
5
4
|
import { COMMON_IME_CONTROL_KEYS } from '~/src/hooks/useKeyboardActionLockerWhileComposing'
|
|
6
5
|
import { render } from '~/src/utils/test'
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
TEXT_INPUT_CLEAR_ICON_TEST_ID,
|
|
10
|
-
TEXT_INPUT_TEST_ID,
|
|
11
|
-
TextField,
|
|
12
|
-
} from './TextField'
|
|
7
|
+
import { TEXT_INPUT_CLEAR_ICON_TEST_ID, TextField } from './TextField'
|
|
13
8
|
import { type TextFieldProps } from './TextField.types'
|
|
14
9
|
|
|
15
10
|
describe('TextField', () => {
|
|
@@ -29,87 +24,70 @@ describe('TextField', () => {
|
|
|
29
24
|
)
|
|
30
25
|
|
|
31
26
|
it('TextField have default attribute', () => {
|
|
32
|
-
const {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
expect(
|
|
36
|
-
expect(
|
|
37
|
-
expect(
|
|
38
|
-
expect(inputElement).not.toHaveAttribute('maxLength')
|
|
27
|
+
const { getByRole } = renderComponent()
|
|
28
|
+
const input = getByRole('textbox')
|
|
29
|
+
expect(input).not.toHaveAttribute('disabled')
|
|
30
|
+
expect(input).not.toHaveAttribute('readOnly')
|
|
31
|
+
expect(input).not.toHaveAttribute('placeholder')
|
|
32
|
+
expect(input).not.toHaveAttribute('maxLength')
|
|
39
33
|
})
|
|
40
34
|
|
|
41
35
|
it('should have "disabled" attribute when "disabled" props is "true"', () => {
|
|
42
|
-
const {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
expect(inputElement).toHaveAttribute('disabled')
|
|
36
|
+
const { getByRole } = renderComponent({ disabled: true })
|
|
37
|
+
const input = getByRole('textbox')
|
|
38
|
+
expect(input).toHaveAttribute('disabled')
|
|
46
39
|
})
|
|
47
40
|
|
|
48
41
|
it('should have "readOnly" attribute when "readOnly" props is "true"', () => {
|
|
49
|
-
const {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
expect(inputElement).toHaveAttribute('readOnly')
|
|
42
|
+
const { getByRole } = renderComponent({ readOnly: true })
|
|
43
|
+
const input = getByRole('textbox')
|
|
44
|
+
expect(input).toHaveAttribute('readOnly')
|
|
53
45
|
})
|
|
54
46
|
|
|
55
47
|
it('should have "placeholder" attribute when "placeholder" props is "true"', () => {
|
|
56
|
-
const {
|
|
48
|
+
const { getByRole } = renderComponent({
|
|
57
49
|
placeholder: 'this is placeholder',
|
|
58
50
|
})
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
expect(inputElement).toHaveAttribute('placeholder', 'this is placeholder')
|
|
51
|
+
const input = getByRole('textbox')
|
|
52
|
+
expect(input).toHaveAttribute('placeholder', 'this is placeholder')
|
|
62
53
|
})
|
|
63
54
|
|
|
64
55
|
it('should have "maxLength" attribute when "maxLength" props is "true"', () => {
|
|
65
|
-
const {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
expect(inputElement).toHaveAttribute('maxLength', '5')
|
|
56
|
+
const { getByRole } = renderComponent({ maxLength: 5 })
|
|
57
|
+
const input = getByRole('textbox')
|
|
58
|
+
expect(input).toHaveAttribute('maxLength', '5')
|
|
69
59
|
})
|
|
70
60
|
|
|
71
|
-
describe('callback should called', () => {
|
|
61
|
+
describe('callback should be called', () => {
|
|
72
62
|
it('onFocus', () => {
|
|
73
63
|
const onFocus = jest.fn()
|
|
74
|
-
const {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
act(() => {
|
|
78
|
-
input.focus()
|
|
79
|
-
})
|
|
64
|
+
const { getByRole } = renderComponent({ onFocus })
|
|
65
|
+
const input = getByRole('textbox')
|
|
66
|
+
input.focus()
|
|
80
67
|
expect(onFocus).toHaveBeenCalled()
|
|
81
68
|
})
|
|
82
69
|
|
|
83
70
|
it('onChange', () => {
|
|
84
71
|
const onChange = jest.fn()
|
|
85
|
-
const {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
act(() => {
|
|
89
|
-
fireEvent.change(input, { target: { value: 'test' } })
|
|
90
|
-
})
|
|
72
|
+
const { getByRole } = renderComponent({ onChange })
|
|
73
|
+
const input = getByRole('textbox')
|
|
74
|
+
fireEvent.change(input, { target: { value: 'test' } })
|
|
91
75
|
expect(onChange).toHaveBeenCalled()
|
|
92
76
|
})
|
|
93
77
|
|
|
94
78
|
it('onKeyDown', () => {
|
|
95
79
|
const onKeyDown = jest.fn()
|
|
96
|
-
const {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
act(() => {
|
|
100
|
-
fireEvent.keyDown(input, { key: 'A', code: 'KeyA' })
|
|
101
|
-
})
|
|
80
|
+
const { getByRole } = renderComponent({ onKeyDown })
|
|
81
|
+
const input = getByRole('textbox')
|
|
82
|
+
fireEvent.keyDown(input, { key: 'A', code: 'KeyA' })
|
|
102
83
|
expect(onKeyDown).toHaveBeenCalled()
|
|
103
84
|
})
|
|
104
85
|
|
|
105
86
|
it('onKeyUp', () => {
|
|
106
87
|
const onKeyUp = jest.fn()
|
|
107
|
-
const {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
act(() => {
|
|
111
|
-
fireEvent.keyUp(input, { key: 'A', code: 'KeyA' })
|
|
112
|
-
})
|
|
88
|
+
const { getByRole } = renderComponent({ onKeyUp })
|
|
89
|
+
const input = getByRole('textbox')
|
|
90
|
+
fireEvent.keyUp(input, { key: 'A', code: 'KeyA' })
|
|
113
91
|
expect(onKeyUp).toHaveBeenCalled()
|
|
114
92
|
})
|
|
115
93
|
})
|
|
@@ -117,89 +95,65 @@ describe('TextField', () => {
|
|
|
117
95
|
describe('no callback should called when "disabled" or "readOnly" props are "true"', () => {
|
|
118
96
|
it('onFocus, disabled', () => {
|
|
119
97
|
const onFocus = jest.fn()
|
|
120
|
-
const {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
act(() => {
|
|
124
|
-
input.focus()
|
|
125
|
-
})
|
|
98
|
+
const { getByRole } = renderComponent({ onFocus, disabled: true })
|
|
99
|
+
const input = getByRole('textbox')
|
|
100
|
+
input.focus()
|
|
126
101
|
expect(onFocus).not.toHaveBeenCalled()
|
|
127
102
|
})
|
|
128
103
|
|
|
129
104
|
it('onFocus, readOnly', () => {
|
|
130
105
|
const onFocus = jest.fn()
|
|
131
|
-
const {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
act(() => {
|
|
135
|
-
input.focus()
|
|
136
|
-
})
|
|
106
|
+
const { getByRole } = renderComponent({ onFocus, readOnly: true })
|
|
107
|
+
const input = getByRole('textbox')
|
|
108
|
+
input.focus()
|
|
137
109
|
expect(onFocus).not.toHaveBeenCalled()
|
|
138
110
|
})
|
|
139
111
|
|
|
140
112
|
it('onChange, disabled', () => {
|
|
141
113
|
const onChange = jest.fn()
|
|
142
|
-
const {
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
act(() => {
|
|
146
|
-
fireEvent.change(input, { target: { value: 'test' } })
|
|
147
|
-
})
|
|
114
|
+
const { getByRole } = renderComponent({ onChange, disabled: true })
|
|
115
|
+
const input = getByRole('textbox')
|
|
116
|
+
fireEvent.change(input, { target: { value: 'test' } })
|
|
148
117
|
expect(onChange).not.toHaveBeenCalled()
|
|
149
118
|
})
|
|
150
119
|
|
|
151
120
|
it('onChange, readOnly', () => {
|
|
152
121
|
const onChange = jest.fn()
|
|
153
|
-
const {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
act(() => {
|
|
157
|
-
fireEvent.change(input, { target: { value: 'test' } })
|
|
158
|
-
})
|
|
122
|
+
const { getByRole } = renderComponent({ onChange, readOnly: true })
|
|
123
|
+
const input = getByRole('textbox')
|
|
124
|
+
fireEvent.change(input, { target: { value: 'test' } })
|
|
159
125
|
expect(onChange).not.toHaveBeenCalled()
|
|
160
126
|
})
|
|
161
127
|
|
|
162
128
|
it('onKeyDown, disabled', () => {
|
|
163
129
|
const onKeyDown = jest.fn()
|
|
164
|
-
const {
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
act(() => {
|
|
168
|
-
fireEvent.keyDown(input, { key: 'A', code: 'KeyA' })
|
|
169
|
-
})
|
|
130
|
+
const { getByRole } = renderComponent({ onKeyDown, disabled: true })
|
|
131
|
+
const input = getByRole('textbox')
|
|
132
|
+
fireEvent.keyDown(input, { key: 'A', code: 'KeyA' })
|
|
170
133
|
expect(onKeyDown).not.toHaveBeenCalled()
|
|
171
134
|
})
|
|
172
135
|
|
|
173
136
|
it('onKeyDown, readOnly', () => {
|
|
174
137
|
const onKeyDown = jest.fn()
|
|
175
|
-
const {
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
act(() => {
|
|
179
|
-
fireEvent.keyDown(input, { key: 'A', code: 'KeyA' })
|
|
180
|
-
})
|
|
138
|
+
const { getByRole } = renderComponent({ onKeyDown, readOnly: true })
|
|
139
|
+
const input = getByRole('textbox')
|
|
140
|
+
fireEvent.keyDown(input, { key: 'A', code: 'KeyA' })
|
|
181
141
|
expect(onKeyDown).not.toHaveBeenCalled()
|
|
182
142
|
})
|
|
183
143
|
|
|
184
144
|
it('onKeyUp, disabled', () => {
|
|
185
145
|
const onKeyUp = jest.fn()
|
|
186
|
-
const {
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
act(() => {
|
|
190
|
-
fireEvent.keyUp(input, { key: 'A', code: 'KeyA' })
|
|
191
|
-
})
|
|
146
|
+
const { getByRole } = renderComponent({ onKeyUp, disabled: true })
|
|
147
|
+
const input = getByRole('textbox')
|
|
148
|
+
fireEvent.keyUp(input, { key: 'A', code: 'KeyA' })
|
|
192
149
|
expect(onKeyUp).not.toHaveBeenCalled()
|
|
193
150
|
})
|
|
194
151
|
|
|
195
152
|
it('onKeyUp, readOnly', () => {
|
|
196
153
|
const onKeyUp = jest.fn()
|
|
197
|
-
const {
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
act(() => {
|
|
201
|
-
fireEvent.keyUp(input, { key: 'A', code: 'KeyA' })
|
|
202
|
-
})
|
|
154
|
+
const { getByRole } = renderComponent({ onKeyUp, readOnly: true })
|
|
155
|
+
const input = getByRole('textbox')
|
|
156
|
+
fireEvent.keyUp(input, { key: 'A', code: 'KeyA' })
|
|
203
157
|
expect(onKeyUp).not.toHaveBeenCalled()
|
|
204
158
|
})
|
|
205
159
|
})
|
|
@@ -207,9 +161,8 @@ describe('TextField', () => {
|
|
|
207
161
|
describe('Keyboard event handlers for common ime control keys should not be called while composing', () => {
|
|
208
162
|
it('onKeyDown', async () => {
|
|
209
163
|
const onKeyDown = jest.fn()
|
|
210
|
-
const {
|
|
211
|
-
const
|
|
212
|
-
const input = rendered.getElementsByTagName('input')[0]
|
|
164
|
+
const { getByRole } = renderComponent({ onKeyDown })
|
|
165
|
+
const input = getByRole('textbox')
|
|
213
166
|
|
|
214
167
|
COMMON_IME_CONTROL_KEYS.forEach(async (key) => {
|
|
215
168
|
const isCompositionStartFired = fireEvent.compositionStart(input)
|
|
@@ -220,9 +173,8 @@ describe('TextField', () => {
|
|
|
220
173
|
|
|
221
174
|
it('onKeyUp', () => {
|
|
222
175
|
const onKeyUp = jest.fn()
|
|
223
|
-
const {
|
|
224
|
-
const
|
|
225
|
-
const input = rendered.getElementsByTagName('input')[0]
|
|
176
|
+
const { getByRole } = renderComponent({ onKeyUp })
|
|
177
|
+
const input = getByRole('textbox')
|
|
226
178
|
|
|
227
179
|
COMMON_IME_CONTROL_KEYS.forEach((key) => {
|
|
228
180
|
const isCompositionStartFired = fireEvent.compositionStart(input)
|
|
@@ -243,10 +195,8 @@ describe('TextField', () => {
|
|
|
243
195
|
// const rendered = getByTestId(TEXT_INPUT_TEST_ID)
|
|
244
196
|
// const input = rendered.getElementsByTagName('input')[0]
|
|
245
197
|
|
|
246
|
-
// await
|
|
247
|
-
//
|
|
248
|
-
// input.focus()
|
|
249
|
-
// })
|
|
198
|
+
// await user.hover(input)
|
|
199
|
+
// input.focus()
|
|
250
200
|
|
|
251
201
|
// const clearButton = within(rendered).queryByTestId(TEXT_INPUT_CLEAR_ICON_TEST_ID)
|
|
252
202
|
// expect(clearButton).not.toBeVisible()
|
|
@@ -261,48 +211,37 @@ describe('TextField', () => {
|
|
|
261
211
|
// })
|
|
262
212
|
|
|
263
213
|
it('appear when filled & hovered', async () => {
|
|
264
|
-
const { getByTestId } = renderComponent({
|
|
214
|
+
const { getByRole, getByTestId } = renderComponent({
|
|
265
215
|
value: 'test',
|
|
266
216
|
allowClear: true,
|
|
267
217
|
})
|
|
268
|
-
const
|
|
269
|
-
const input = rendered.getElementsByTagName('input')[0]
|
|
218
|
+
const input = getByRole('textbox')
|
|
270
219
|
|
|
271
|
-
await
|
|
272
|
-
await user.hover(input)
|
|
273
|
-
})
|
|
220
|
+
await user.hover(input)
|
|
274
221
|
|
|
275
|
-
const clearButton =
|
|
276
|
-
TEXT_INPUT_CLEAR_ICON_TEST_ID
|
|
277
|
-
)
|
|
222
|
+
const clearButton = getByTestId(TEXT_INPUT_CLEAR_ICON_TEST_ID)
|
|
278
223
|
expect(clearButton).toBeVisible()
|
|
279
224
|
})
|
|
280
225
|
|
|
281
226
|
it('appear when filled & focused', () => {
|
|
282
|
-
const { getByTestId } = renderComponent({
|
|
227
|
+
const { getByRole, getByTestId } = renderComponent({
|
|
283
228
|
value: 'test',
|
|
284
229
|
allowClear: true,
|
|
285
230
|
})
|
|
286
|
-
const
|
|
287
|
-
const input = rendered.getElementsByTagName('input')[0]
|
|
231
|
+
const input = getByRole('textbox')
|
|
288
232
|
|
|
289
|
-
|
|
290
|
-
input.focus()
|
|
291
|
-
})
|
|
233
|
+
input.focus()
|
|
292
234
|
|
|
293
|
-
const clearButton =
|
|
294
|
-
TEXT_INPUT_CLEAR_ICON_TEST_ID
|
|
295
|
-
)
|
|
235
|
+
const clearButton = getByTestId(TEXT_INPUT_CLEAR_ICON_TEST_ID)
|
|
296
236
|
expect(clearButton).toBeVisible()
|
|
297
237
|
})
|
|
298
238
|
|
|
299
239
|
it('should focus the clear button when Tab key is pressed', async () => {
|
|
300
|
-
const {
|
|
240
|
+
const { getByRole } = renderComponent({
|
|
301
241
|
value: 'test',
|
|
302
242
|
allowClear: true,
|
|
303
243
|
})
|
|
304
|
-
const
|
|
305
|
-
const input = rendered.getElementsByTagName('input')[0]
|
|
244
|
+
const input = getByRole('textbox')
|
|
306
245
|
|
|
307
246
|
input.focus()
|
|
308
247
|
await user.tab()
|
|
@@ -17,7 +17,7 @@ describe('Toast', () => {
|
|
|
17
17
|
const { getByRole } = renderToast({ onDismiss, autoDismiss: false })
|
|
18
18
|
const toast = getByRole('status')
|
|
19
19
|
const closeButton = getByRole('button')
|
|
20
|
-
|
|
20
|
+
fireEvent.click(closeButton)
|
|
21
21
|
expect(onDismiss).not.toHaveBeenCalled()
|
|
22
22
|
const animationEndEvent = new Event('animationend', {
|
|
23
23
|
bubbles: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { renderHook, waitFor } from '@testing-library/react'
|
|
2
2
|
|
|
3
3
|
import { type ToastType } from './Toast.types'
|
|
4
4
|
import useToastContextValues from './useToastContextValues'
|
|
@@ -19,37 +19,37 @@ describe('useToastContextValues', () => {
|
|
|
19
19
|
expect(result.current.rightToasts).toStrictEqual([])
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
it('add()', () => {
|
|
22
|
+
it('add()', async () => {
|
|
23
23
|
const { result } = renderHook(() => useToastContextValues())
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
await waitFor(() => {
|
|
26
26
|
result.current.add('0')
|
|
27
|
-
})
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
expect(result.current.leftToasts).toStrictEqual([
|
|
29
|
+
expect.objectContaining({
|
|
30
|
+
autoDismiss: false,
|
|
31
|
+
rightSide: false,
|
|
32
|
+
id: expect.stringMatching(UUID_V4_REGEX),
|
|
33
|
+
content: '0',
|
|
34
|
+
version: 0,
|
|
35
|
+
}),
|
|
36
|
+
])
|
|
37
|
+
})
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
describe('update()', () => {
|
|
41
|
-
it('not found', () => {
|
|
41
|
+
it('not found', async () => {
|
|
42
42
|
const { result } = renderHook(() => useToastContextValues())
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
await waitFor(() => {
|
|
45
45
|
expect(result.current.update('0', 'Not found')).toBe('')
|
|
46
46
|
})
|
|
47
47
|
})
|
|
48
48
|
|
|
49
|
-
it('updated', () => {
|
|
49
|
+
it('updated', async () => {
|
|
50
50
|
const { result } = renderHook(() => useToastContextValues())
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
await waitFor(() => {
|
|
53
53
|
result.current.add('0')
|
|
54
54
|
})
|
|
55
55
|
const targetIndex = 0
|
|
@@ -58,7 +58,7 @@ describe('useToastContextValues', () => {
|
|
|
58
58
|
...targetToast,
|
|
59
59
|
content: 'New Toast',
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
await waitFor(() => {
|
|
62
62
|
expect(
|
|
63
63
|
result.current.update(updateTargetToast.id, updateTargetToast.content)
|
|
64
64
|
).toBe(updateTargetToast.id)
|
|
@@ -71,11 +71,11 @@ describe('useToastContextValues', () => {
|
|
|
71
71
|
})
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
it('remove()', () => {
|
|
74
|
+
it('remove()', async () => {
|
|
75
75
|
const { result } = renderHook(() => useToastContextValues())
|
|
76
76
|
|
|
77
77
|
let toastId: string
|
|
78
|
-
|
|
78
|
+
await waitFor(() => {
|
|
79
79
|
toastId = result.current.add('0')
|
|
80
80
|
})
|
|
81
81
|
expect(result.current.leftToasts).toStrictEqual([
|
|
@@ -87,17 +87,17 @@ describe('useToastContextValues', () => {
|
|
|
87
87
|
version: 0,
|
|
88
88
|
}),
|
|
89
89
|
])
|
|
90
|
-
|
|
90
|
+
await waitFor(() => {
|
|
91
91
|
result.current.remove(toastId)
|
|
92
92
|
})
|
|
93
93
|
expect(result.current.leftToasts).toStrictEqual([])
|
|
94
94
|
expect(result.current.rightToasts).toStrictEqual([])
|
|
95
95
|
})
|
|
96
96
|
|
|
97
|
-
it('removeAll()', () => {
|
|
97
|
+
it('removeAll()', async () => {
|
|
98
98
|
const { result } = renderHook(() => useToastContextValues())
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
await waitFor(() => {
|
|
101
101
|
result.current.add('0')
|
|
102
102
|
})
|
|
103
103
|
|
|
@@ -111,19 +111,19 @@ describe('useToastContextValues', () => {
|
|
|
111
111
|
}),
|
|
112
112
|
])
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
await waitFor(() => {
|
|
115
115
|
result.current.removeAll()
|
|
116
116
|
})
|
|
117
117
|
expect(result.current.leftToasts).toStrictEqual([])
|
|
118
118
|
expect(result.current.rightToasts).toStrictEqual([])
|
|
119
119
|
})
|
|
120
120
|
|
|
121
|
-
it('dismiss()', () => {
|
|
121
|
+
it('dismiss()', async () => {
|
|
122
122
|
const onDismiss = jest.fn()
|
|
123
123
|
const { result } = renderHook(() => useToastContextValues())
|
|
124
124
|
|
|
125
125
|
let toastId: string
|
|
126
|
-
|
|
126
|
+
await waitFor(() => {
|
|
127
127
|
toastId = result.current.add('0')
|
|
128
128
|
})
|
|
129
129
|
expect(result.current.leftToasts).toStrictEqual([
|
|
@@ -135,7 +135,7 @@ describe('useToastContextValues', () => {
|
|
|
135
135
|
version: 0,
|
|
136
136
|
}),
|
|
137
137
|
])
|
|
138
|
-
|
|
138
|
+
await waitFor(() => {
|
|
139
139
|
result.current.dismiss(toastId, onDismiss)
|
|
140
140
|
})
|
|
141
141
|
expect(onDismiss).toHaveBeenCalledTimes(1)
|