Skip to content

Commit baf7bce

Browse files
committed
fix(file-upload): Apply feedbacks
1 parent 5a542c5 commit baf7bce

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/components/Form/FieldUpload/FieldUpload.spec.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ test('default value', async () => {
7676

7777
// Here we can use '!' on mockFile.name to prevent TS error because we are sure it is defined
7878
const input = screen.getByLabelText<HTMLInputElement>(mockFile.name!);
79-
await user.upload(input, mockFile.file ?? []);
80-
expect(input.files ? input.files[0] : []).toBe(mockFile.file);
79+
expect(input.files ? input.files[0] : []).toBe(undefined);
8180
await user.click(screen.getByRole('button', { name: 'Submit' }));
8281
expect(mockedSubmit).toHaveBeenCalledWith({ file: mockFile });
8382
});

src/components/Form/FieldUpload/docs.stories.tsx

+3-18
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@ export const Default = () => {
3535
return (
3636
<Form {...form} onSubmit={(values) => console.log(values)}>
3737
<Stack spacing={4}>
38-
<FormField
39-
control={form.control}
40-
type="upload"
41-
name="file"
42-
label="Name"
43-
/>
38+
<FormField type="upload" name="file" label="Name" />
4439
<Box>
4540
<Button type="submit" variant="@primary">
4641
Submit
@@ -66,12 +61,7 @@ export const WithDefaultValue = () => {
6661
return (
6762
<Form {...form} onSubmit={(values) => console.log(values)}>
6863
<Stack spacing={4}>
69-
<FormField
70-
control={form.control}
71-
type="upload"
72-
name="file"
73-
label="Name"
74-
/>
64+
<FormField type="upload" name="file" label="Name" />
7565
<Box>
7666
<Button type="submit" variant="@primary">
7767
Submit
@@ -97,12 +87,7 @@ export const WithPreview = () => {
9787
return (
9888
<Form {...form} onSubmit={(values) => console.log(values)}>
9989
<Stack spacing={4}>
100-
<FormField
101-
control={form.control}
102-
type="upload"
103-
name="file"
104-
label="Name"
105-
/>
90+
<FormField type="upload" name="file" label="Name" />
10691
<FieldUploadPreview uploaderName="file" />
10792
<Box>
10893
<Button type="submit" variant="@primary">

0 commit comments

Comments
 (0)