@seed-design/react 1.2.1 → 1.2.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/lib/components/Dialog/Dialog.cjs +1 -6
- package/lib/components/Dialog/Dialog.d.ts +1 -1
- package/lib/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/components/Dialog/Dialog.js +1 -6
- package/lib/components/TextField/TextField.test.d.ts +1 -0
- package/lib/components/TextField/TextField.test.d.ts.map +1 -1
- package/lib/components/TextField/useTextFieldWithGraphemes.test.d.ts +1 -0
- package/lib/components/TextField/useTextFieldWithGraphemes.test.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/Dialog/Dialog.tsx +1 -5
- package/src/components/TextField/TextField.test.tsx +17 -25
- package/src/components/TextField/useTextFieldWithGraphemes.test.tsx +17 -17
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
5
|
|
|
6
|
-
const jsxRuntime = require('react/jsx-runtime');
|
|
7
6
|
const reactDialog = require('@seed-design/react-dialog');
|
|
8
7
|
const reactPrimitive = require('@seed-design/react-primitive');
|
|
9
8
|
const dialog = require('@seed-design/css/recipes/dialog');
|
|
10
|
-
const React = require('react');
|
|
11
9
|
const createSlotRecipeContext = require('../../utils/createSlotRecipeContext.cjs');
|
|
12
10
|
const createWithStateProps = require('../../utils/createWithStateProps.cjs');
|
|
13
11
|
|
|
@@ -42,10 +40,7 @@ const DialogDescription = withContext(
|
|
|
42
40
|
"description"
|
|
43
41
|
);
|
|
44
42
|
const DialogFooter = withContext(reactPrimitive.Primitive.div, "footer");
|
|
45
|
-
const DialogAction =
|
|
46
|
-
const api = reactDialog.useDialogContext();
|
|
47
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactPrimitive.Primitive.button, { ...props, ref, onClick: () => api.setOpen(false) });
|
|
48
|
-
});
|
|
43
|
+
const DialogAction = reactDialog.Dialog.CloseButton;
|
|
49
44
|
|
|
50
45
|
exports.DialogAction = DialogAction;
|
|
51
46
|
exports.DialogBackdrop = DialogBackdrop;
|
|
@@ -39,5 +39,5 @@ export interface DialogFooterProps extends PrimitiveProps, React.HTMLAttributes<
|
|
|
39
39
|
export declare const DialogFooter: ForwardRefExoticComponent<DialogFooterProps & RefAttributes<HTMLDivElement>>;
|
|
40
40
|
export interface DialogActionProps extends PrimitiveProps, React.HTMLAttributes<HTMLButtonElement> {
|
|
41
41
|
}
|
|
42
|
-
export declare const DialogAction: ForwardRefExoticComponent<
|
|
42
|
+
export declare const DialogAction: ForwardRefExoticComponent<DialogPrimitive.CloseButtonProps & RefAttributes<HTMLButtonElement>>;
|
|
43
43
|
//# sourceMappingURL=Dialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAoB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAU,KAAK,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAoB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAU,KAAK,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AASlF,MAAM,WAAW,eAAgB,SAAQ,kBAAkB,EAAE,eAAe,CAAC,SAAS;IACpF;;OAEG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACnD;;OAEG;IACH,aAAa,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;CAC5D;AAED,eAAO,MAAM,UAAU,4DAKrB,CAAC;AAIH,MAAM,WAAW,kBAAmB,SAAQ,eAAe,CAAC,YAAY;CAAG;AAE3E,eAAO,MAAM,aAAa,4HAA0B,CAAC;AAIrD,MAAM,WAAW,qBAAsB,SAAQ,eAAe,CAAC,eAAe;CAAG;AAEjF,eAAO,MAAM,gBAAgB,kHAG5B,CAAC;AAIF,MAAM,WAAW,mBAAoB,SAAQ,eAAe,CAAC,aAAa;CAAG;AAE7E,eAAO,MAAM,cAAc,gHAG1B,CAAC;AAIF,MAAM,WAAW,kBAAmB,SAAQ,eAAe,CAAC,YAAY;CAAG;AAE3E,eAAO,MAAM,aAAa,+GAGzB,CAAC;AAIF,MAAM,WAAW,iBAAkB,SAAQ,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;CAAG;AAElG,eAAO,MAAM,YAAY,8GAA0E,CAAC;AAOpG,MAAM,WAAW,gBAAiB,SAAQ,eAAe,CAAC,UAAU;CAAG;AAEvE,eAAO,MAAM,WAAW,iHAGvB,CAAC;AAOF,MAAM,WAAW,sBAAuB,SAAQ,eAAe,CAAC,gBAAgB;CAAG;AAEnF,eAAO,MAAM,iBAAiB,yHAG7B,CAAC;AAIF,MAAM,WAAW,iBAAkB,SAAQ,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;CAAG;AAElG,eAAO,MAAM,YAAY,8GAA0E,CAAC;AAIpG,MAAM,WAAW,iBACf,SAAQ,cAAc,EACpB,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC;CAAG;AAE9C,eAAO,MAAM,YAAY,gIAA8B,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
2
|
import { Dialog, useDialogContext } from '@seed-design/react-dialog';
|
|
4
3
|
import { Primitive } from '@seed-design/react-primitive';
|
|
5
4
|
import { dialog } from '@seed-design/css/recipes/dialog';
|
|
6
|
-
import { forwardRef } from 'react';
|
|
7
5
|
import { createSlotRecipeContext } from '../../utils/createSlotRecipeContext.js';
|
|
8
6
|
import { createWithStateProps } from '../../utils/createWithStateProps.js';
|
|
9
7
|
|
|
@@ -38,9 +36,6 @@ const DialogDescription = withContext(
|
|
|
38
36
|
"description"
|
|
39
37
|
);
|
|
40
38
|
const DialogFooter = withContext(Primitive.div, "footer");
|
|
41
|
-
const DialogAction =
|
|
42
|
-
const api = useDialogContext();
|
|
43
|
-
return /* @__PURE__ */ jsx(Primitive.button, { ...props, ref, onClick: () => api.setOpen(false) });
|
|
44
|
-
});
|
|
39
|
+
const DialogAction = Dialog.CloseButton;
|
|
45
40
|
|
|
46
41
|
export { DialogAction, DialogBackdrop, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogPositioner, DialogRoot, DialogTitle, DialogTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.test.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextField.test.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextFieldWithGraphemes.test.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/useTextFieldWithGraphemes.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTextFieldWithGraphemes.test.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/useTextFieldWithGraphemes.test.tsx"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seed-design/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/daangn/seed-design.git",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@seed-design/react-avatar": "1.0.0",
|
|
45
45
|
"@seed-design/react-checkbox": "1.0.1",
|
|
46
46
|
"@seed-design/react-collapsible": "0.1.0",
|
|
47
|
-
"@seed-design/react-dialog": "1.0.
|
|
48
|
-
"@seed-design/react-drawer": "1.0.
|
|
47
|
+
"@seed-design/react-dialog": "1.0.2",
|
|
48
|
+
"@seed-design/react-drawer": "1.0.8",
|
|
49
49
|
"@seed-design/react-field": "1.0.1",
|
|
50
50
|
"@seed-design/react-image": "0.1.0",
|
|
51
51
|
"@seed-design/react-fieldset": "0.1.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@seed-design/react-radio-group": "1.1.0",
|
|
59
59
|
"@seed-design/react-segmented-control": "1.0.1",
|
|
60
60
|
"@seed-design/react-slider": "1.0.1",
|
|
61
|
-
"@seed-design/react-snackbar": "1.0.
|
|
61
|
+
"@seed-design/react-snackbar": "1.0.1",
|
|
62
62
|
"@seed-design/react-switch": "1.0.1",
|
|
63
63
|
"@seed-design/react-tabs": "1.0.2",
|
|
64
64
|
"@seed-design/react-text-field": "1.1.1",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dialog as DialogPrimitive, useDialogContext } from "@seed-design/react-dialog";
|
|
2
2
|
import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive";
|
|
3
3
|
import { dialog, type DialogVariantProps } from "@seed-design/css/recipes/dialog";
|
|
4
|
-
import { forwardRef } from "react";
|
|
5
4
|
import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext";
|
|
6
5
|
import { createWithStateProps } from "../../utils/createWithStateProps";
|
|
7
6
|
|
|
@@ -103,7 +102,4 @@ export interface DialogActionProps
|
|
|
103
102
|
extends PrimitiveProps,
|
|
104
103
|
React.HTMLAttributes<HTMLButtonElement> {}
|
|
105
104
|
|
|
106
|
-
export const DialogAction =
|
|
107
|
-
const api = useDialogContext();
|
|
108
|
-
return <Primitive.button {...props} ref={ref} onClick={() => api.setOpen(false)} />;
|
|
109
|
-
});
|
|
105
|
+
export const DialogAction = DialogPrimitive.CloseButton;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "@testing-library/
|
|
2
|
-
import { cleanup, render } from "@testing-library/react";
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
3
2
|
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import {
|
|
3
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
5
4
|
import type { ReactElement } from "react";
|
|
6
5
|
import React from "react";
|
|
7
6
|
|
|
@@ -16,8 +15,6 @@ import {
|
|
|
16
15
|
TextFieldSuffixText,
|
|
17
16
|
} from "./TextField";
|
|
18
17
|
|
|
19
|
-
afterEach(cleanup);
|
|
20
|
-
|
|
21
18
|
function setUp(jsx: ReactElement) {
|
|
22
19
|
return {
|
|
23
20
|
user: userEvent.setup(),
|
|
@@ -26,17 +23,12 @@ function setUp(jsx: ReactElement) {
|
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
describe("TextField", () => {
|
|
29
|
-
global.CSS = {
|
|
30
|
-
// @ts-expect-error
|
|
31
|
-
supports: (_k, _v) => true,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
26
|
describe("props merging", () => {
|
|
35
27
|
describe("TextFieldInput", () => {
|
|
36
28
|
it("should merge props from TextFieldRoot", () => {
|
|
37
29
|
const { getByRole } = setUp(
|
|
38
30
|
<TextFieldRoot defaultValue="initial">
|
|
39
|
-
<TextFieldInput placeholder="Placeholder" />
|
|
31
|
+
<TextFieldInput placeholder="Placeholder" aria-label="Test input" />
|
|
40
32
|
</TextFieldRoot>,
|
|
41
33
|
);
|
|
42
34
|
|
|
@@ -49,7 +41,7 @@ describe("TextField", () => {
|
|
|
49
41
|
const { getByRole } = setUp(
|
|
50
42
|
<Field.Root required invalid disabled name="test-field">
|
|
51
43
|
<TextFieldRoot>
|
|
52
|
-
<TextFieldInput />
|
|
44
|
+
<TextFieldInput aria-label="Test input" />
|
|
53
45
|
</TextFieldRoot>
|
|
54
46
|
</Field.Root>,
|
|
55
47
|
);
|
|
@@ -65,7 +57,7 @@ describe("TextField", () => {
|
|
|
65
57
|
const { getByRole } = setUp(
|
|
66
58
|
<Field.Root name="field-name">
|
|
67
59
|
<TextFieldRoot>
|
|
68
|
-
<TextFieldInput name="direct-name" />
|
|
60
|
+
<TextFieldInput name="direct-name" aria-label="Test input" />
|
|
69
61
|
</TextFieldRoot>
|
|
70
62
|
</Field.Root>,
|
|
71
63
|
);
|
|
@@ -78,7 +70,7 @@ describe("TextField", () => {
|
|
|
78
70
|
const { getByRole } = setUp(
|
|
79
71
|
<Field.Root disabled readOnly invalid>
|
|
80
72
|
<TextFieldRoot>
|
|
81
|
-
<TextFieldInput data-custom="value" />
|
|
73
|
+
<TextFieldInput data-custom="value" aria-label="Test input" />
|
|
82
74
|
</TextFieldRoot>
|
|
83
75
|
</Field.Root>,
|
|
84
76
|
);
|
|
@@ -91,10 +83,10 @@ describe("TextField", () => {
|
|
|
91
83
|
});
|
|
92
84
|
|
|
93
85
|
it("should handle uncontrolled modes", async () => {
|
|
94
|
-
const handleChange =
|
|
86
|
+
const handleChange = mock(() => {});
|
|
95
87
|
const { getByRole, user } = setUp(
|
|
96
88
|
<TextFieldRoot onValueChange={handleChange}>
|
|
97
|
-
<TextFieldInput />
|
|
89
|
+
<TextFieldInput aria-label="Test input" />
|
|
98
90
|
</TextFieldRoot>,
|
|
99
91
|
);
|
|
100
92
|
|
|
@@ -110,7 +102,7 @@ describe("TextField", () => {
|
|
|
110
102
|
|
|
111
103
|
return (
|
|
112
104
|
<TextFieldRoot value={value} onValueChange={setValue}>
|
|
113
|
-
<TextFieldInput />
|
|
105
|
+
<TextFieldInput aria-label="Test input" />
|
|
114
106
|
</TextFieldRoot>
|
|
115
107
|
);
|
|
116
108
|
}
|
|
@@ -128,7 +120,7 @@ describe("TextField", () => {
|
|
|
128
120
|
it("should merge props from TextFieldRoot", () => {
|
|
129
121
|
const { getByRole } = setUp(
|
|
130
122
|
<TextFieldRoot defaultValue="initial">
|
|
131
|
-
<TextFieldTextarea placeholder="Placeholder" />
|
|
123
|
+
<TextFieldTextarea placeholder="Placeholder" aria-label="Test textarea" />
|
|
132
124
|
</TextFieldRoot>,
|
|
133
125
|
);
|
|
134
126
|
|
|
@@ -141,7 +133,7 @@ describe("TextField", () => {
|
|
|
141
133
|
const { getByRole } = setUp(
|
|
142
134
|
<Field.Root required invalid disabled name="test-field">
|
|
143
135
|
<TextFieldRoot>
|
|
144
|
-
<TextFieldTextarea />
|
|
136
|
+
<TextFieldTextarea aria-label="Test textarea" />
|
|
145
137
|
</TextFieldRoot>
|
|
146
138
|
</Field.Root>,
|
|
147
139
|
);
|
|
@@ -157,7 +149,7 @@ describe("TextField", () => {
|
|
|
157
149
|
const { getByRole } = setUp(
|
|
158
150
|
<Field.Root disabled name="field-name">
|
|
159
151
|
<TextFieldRoot>
|
|
160
|
-
<TextFieldTextarea disabled={false} name="direct-name" />
|
|
152
|
+
<TextFieldTextarea disabled={false} name="direct-name" aria-label="Test textarea" />
|
|
161
153
|
</TextFieldRoot>
|
|
162
154
|
</Field.Root>,
|
|
163
155
|
);
|
|
@@ -171,7 +163,7 @@ describe("TextField", () => {
|
|
|
171
163
|
const { getByRole } = setUp(
|
|
172
164
|
<Field.Root disabled readOnly invalid>
|
|
173
165
|
<TextFieldRoot>
|
|
174
|
-
<TextFieldTextarea data-custom="value" />
|
|
166
|
+
<TextFieldTextarea data-custom="value" aria-label="Test textarea" />
|
|
175
167
|
</TextFieldRoot>
|
|
176
168
|
</Field.Root>,
|
|
177
169
|
);
|
|
@@ -184,10 +176,10 @@ describe("TextField", () => {
|
|
|
184
176
|
});
|
|
185
177
|
|
|
186
178
|
it("should handle uncontrolled modes", async () => {
|
|
187
|
-
const handleChange =
|
|
179
|
+
const handleChange = mock(() => {});
|
|
188
180
|
const { getByRole, user } = setUp(
|
|
189
181
|
<TextFieldRoot onValueChange={handleChange}>
|
|
190
|
-
<TextFieldTextarea />
|
|
182
|
+
<TextFieldTextarea aria-label="Test textarea" />
|
|
191
183
|
</TextFieldRoot>,
|
|
192
184
|
);
|
|
193
185
|
|
|
@@ -203,7 +195,7 @@ describe("TextField", () => {
|
|
|
203
195
|
|
|
204
196
|
return (
|
|
205
197
|
<TextFieldRoot value={value} onValueChange={setValue}>
|
|
206
|
-
<TextFieldTextarea />
|
|
198
|
+
<TextFieldTextarea aria-label="Test textarea" />
|
|
207
199
|
</TextFieldRoot>
|
|
208
200
|
);
|
|
209
201
|
}
|
|
@@ -223,7 +215,7 @@ describe("TextField", () => {
|
|
|
223
215
|
<TextFieldRoot disabled invalid readOnly>
|
|
224
216
|
<TextFieldPrefixText>Prefix</TextFieldPrefixText>
|
|
225
217
|
<TextFieldPrefixIcon svg={<svg data-testid="prefix-icon" />} />
|
|
226
|
-
<TextFieldInput />
|
|
218
|
+
<TextFieldInput aria-label="Test input" />
|
|
227
219
|
<TextFieldSuffixIcon svg={<svg data-testid="suffix-icon" />} />
|
|
228
220
|
<TextFieldSuffixText>Suffix</TextFieldSuffixText>
|
|
229
221
|
</TextFieldRoot>,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "@testing-library/
|
|
2
|
-
import { cleanup, render } from "@testing-library/react";
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
3
2
|
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import {
|
|
3
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
5
4
|
import type { ReactElement } from "react";
|
|
6
5
|
import React from "react";
|
|
7
6
|
|
|
@@ -15,8 +14,6 @@ import {
|
|
|
15
14
|
} from "../Field/Field";
|
|
16
15
|
import { useTextFieldWithGraphemes } from "./useTextFieldWithGraphemes";
|
|
17
16
|
|
|
18
|
-
afterEach(cleanup);
|
|
19
|
-
|
|
20
17
|
function setUp(jsx: ReactElement) {
|
|
21
18
|
return {
|
|
22
19
|
user: userEvent.setup(),
|
|
@@ -55,11 +52,6 @@ const TextFieldWithGraphemes = (props: TextFieldWithGraphemesProps) => {
|
|
|
55
52
|
};
|
|
56
53
|
|
|
57
54
|
describe("useTextFieldWithGraphemes", () => {
|
|
58
|
-
global.CSS = {
|
|
59
|
-
// @ts-expect-error
|
|
60
|
-
supports: (_k, _v) => true,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
55
|
describe("basic functionality", () => {
|
|
64
56
|
it("should render with empty default value", () => {
|
|
65
57
|
const { getByTestId } = setUp(<TextFieldWithGraphemes />);
|
|
@@ -153,8 +145,15 @@ describe("useTextFieldWithGraphemes", () => {
|
|
|
153
145
|
});
|
|
154
146
|
|
|
155
147
|
describe("onValueChange callback", () => {
|
|
148
|
+
type ValueChangeParams = {
|
|
149
|
+
value: string;
|
|
150
|
+
graphemes: string[];
|
|
151
|
+
slicedValue: string;
|
|
152
|
+
slicedGraphemes: string[];
|
|
153
|
+
};
|
|
154
|
+
|
|
156
155
|
it("should call onValueChange with correct parameters", async () => {
|
|
157
|
-
const handleValueChange =
|
|
156
|
+
const handleValueChange = mock<(params: ValueChangeParams) => void>(() => {});
|
|
158
157
|
const { getByTestId, user } = setUp(
|
|
159
158
|
<TextFieldWithGraphemes onValueChange={handleValueChange} />,
|
|
160
159
|
);
|
|
@@ -178,7 +177,7 @@ describe("useTextFieldWithGraphemes", () => {
|
|
|
178
177
|
});
|
|
179
178
|
|
|
180
179
|
it("should provide sliced values when maxGraphemes is set", async () => {
|
|
181
|
-
const handleValueChange =
|
|
180
|
+
const handleValueChange = mock<(params: ValueChangeParams) => void>(() => {});
|
|
182
181
|
const { getByTestId, user } = setUp(
|
|
183
182
|
<TextFieldWithGraphemes maxGraphemeCount={3} onValueChange={handleValueChange} />,
|
|
184
183
|
);
|
|
@@ -186,7 +185,8 @@ describe("useTextFieldWithGraphemes", () => {
|
|
|
186
185
|
|
|
187
186
|
await user.type(input, "Hello");
|
|
188
187
|
|
|
189
|
-
const lastCall = handleValueChange.mock.calls[handleValueChange.mock.calls.length - 1][0];
|
|
188
|
+
const lastCall = handleValueChange.mock.calls[handleValueChange.mock.calls.length - 1]?.[0];
|
|
189
|
+
if (!lastCall) throw new Error("Expected lastCall to be defined");
|
|
190
190
|
|
|
191
191
|
expect(lastCall.value).toBe("Hello");
|
|
192
192
|
expect(lastCall.graphemes).toEqual(["H", "e", "l", "l", "o"]);
|
|
@@ -195,7 +195,7 @@ describe("useTextFieldWithGraphemes", () => {
|
|
|
195
195
|
});
|
|
196
196
|
|
|
197
197
|
it("should handle empty string", async () => {
|
|
198
|
-
const handleValueChange =
|
|
198
|
+
const handleValueChange = mock(() => {});
|
|
199
199
|
const { getByTestId, user } = setUp(
|
|
200
200
|
<TextFieldWithGraphemes defaultValue="Test" onValueChange={handleValueChange} />,
|
|
201
201
|
);
|
|
@@ -212,8 +212,8 @@ describe("useTextFieldWithGraphemes", () => {
|
|
|
212
212
|
});
|
|
213
213
|
|
|
214
214
|
it("should be called in both controlled and uncontrolled modes", async () => {
|
|
215
|
-
const handleUncontrolled =
|
|
216
|
-
const handleControlled =
|
|
215
|
+
const handleUncontrolled = mock<(params: ValueChangeParams) => void>(() => {});
|
|
216
|
+
const handleControlled = mock<(params: ValueChangeParams) => void>(() => {});
|
|
217
217
|
|
|
218
218
|
function TestBothModes() {
|
|
219
219
|
const [controlledValue, setControlledValue] = React.useState("controlled");
|
|
@@ -291,7 +291,7 @@ describe("useTextFieldWithGraphemes", () => {
|
|
|
291
291
|
});
|
|
292
292
|
|
|
293
293
|
it("should call onValueChange even when value doesn't change in controlled mode", async () => {
|
|
294
|
-
const handleValueChange =
|
|
294
|
+
const handleValueChange = mock(() => {});
|
|
295
295
|
const { getByTestId, user } = setUp(
|
|
296
296
|
<TextFieldWithGraphemes value="fixed" onValueChange={handleValueChange} />,
|
|
297
297
|
);
|