Skip to content

Commit a5a7e16

Browse files
committed
fix(Form): internal logic fixes * 3
1 parent 0698223 commit a5a7e16

File tree

13 files changed

+42
-56
lines changed

13 files changed

+42
-56
lines changed

src/components/fields/Checkbox/checkbox-group.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('<CheckboxGroup />', () => {
3030
expect(checkbox[0]).toBeChecked();
3131
expect(checkbox[1]).not.toBeChecked();
3232

33-
await act(async () => await userEvent.click(checkbox[1]));
33+
await userEvent.click(checkbox[1]);
3434

3535
expect(checkbox[0]).toBeChecked();
3636
expect(checkbox[1]).toBeChecked();
@@ -50,7 +50,7 @@ describe('<CheckboxGroup />', () => {
5050
);
5151

5252
const checkbox = getAllByRole('checkbox');
53-
await act(async () => await userEvent.click(checkbox[0]));
53+
await userEvent.click(checkbox[0]);
5454

5555
expect(checkbox[0]).toBeChecked();
5656
expect(checkbox[1]).toBeChecked();

src/components/fields/Checkbox/checkbox.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('<Checkbox />', () => {
1212
const { getByRole } = render(<Checkbox>Test</Checkbox>);
1313
const checkboxElement = getByRole('checkbox');
1414

15-
await act(async () => await userEvent.click(checkboxElement));
15+
await userEvent.click(checkboxElement);
1616

1717
expect(checkboxElement).toBeChecked();
1818
});
@@ -24,7 +24,7 @@ describe('<Checkbox />', () => {
2424

2525
const checkboxElement = getByRole('checkbox');
2626

27-
await act(async () => await userEvent.click(checkboxElement));
27+
await userEvent.click(checkboxElement);
2828

2929
expect(checkboxElement).toBeChecked();
3030
expect(formInstance.getFieldValue('test')).toBe(true);
@@ -39,7 +39,7 @@ describe('<Checkbox />', () => {
3939

4040
const checkboxElement = getByRole('checkbox');
4141

42-
await act(async () => await userEvent.click(checkboxElement));
42+
await userEvent.click(checkboxElement);
4343

4444
expect(checkboxElement).toBeChecked();
4545
expect(formInstance.getFieldValue('test')).toBe(true);

src/components/fields/PasswordInput/password-input.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('<PasswordInput />', () => {
1313

1414
const passwordInput = getByTestId('Input');
1515

16-
await act(async () => await userEvent.type(passwordInput, 'test'));
16+
await userEvent.type(passwordInput, 'test');
1717

1818
expect(passwordInput).toHaveValue('test');
1919
});
@@ -25,7 +25,7 @@ describe('<PasswordInput />', () => {
2525

2626
const passwordInput = getByTestId('Input');
2727

28-
await act(async () => await userEvent.type(passwordInput, 'test'));
28+
await userEvent.type(passwordInput, 'test');
2929

3030
expect(passwordInput).toHaveValue('test');
3131
expect(formInstance.getFieldValue('test')).toBe('test');
@@ -40,7 +40,7 @@ describe('<PasswordInput />', () => {
4040

4141
const passwordInput = getByTestId('Input');
4242

43-
await act(async () => await userEvent.type(passwordInput, 'test'));
43+
await userEvent.type(passwordInput, 'test');
4444

4545
expect(passwordInput).toHaveValue('test');
4646
expect(formInstance.getFieldValue('test')).toBe('test');

src/components/fields/RadioGroup/radio.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('<Radio /> and <RadioGroup />', () => {
1919
</Radio.Group>,
2020
);
2121
const radio = getAllByRole('radio');
22-
await act(async () => await userEvent.click(radio[0]));
22+
await userEvent.click(radio[0]);
2323

2424
expect(radio[0]).toBeChecked();
2525
});
@@ -33,7 +33,7 @@ describe('<Radio /> and <RadioGroup />', () => {
3333
);
3434
const radio = screen.getAllByRole('radio');
3535

36-
await act(async () => await userEvent.click(radio[0]));
36+
await userEvent.click(radio[0]);
3737

3838
expect(radio[0]).toBeChecked();
3939

src/components/fields/Select/select.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ describe('<Select />', () => {
2121
);
2222

2323
const select = getByRole('button');
24-
await act(async () => await userEvent.click(select));
24+
await userEvent.click(select);
2525

2626
const options = getAllByRole('option');
27-
await act(async () => await userEvent.click(options[1]));
27+
await userEvent.click(options[1]);
2828

2929
expect(select).toHaveTextContent('Red');
3030
});
@@ -41,10 +41,10 @@ describe('<Select />', () => {
4141
);
4242

4343
const select = getByRole('button');
44-
await act(async () => await userEvent.click(select));
44+
await userEvent.click(select);
4545

4646
const options = getAllByRole('option');
47-
await act(async () => await userEvent.click(options[1]));
47+
await userEvent.click(options[1]);
4848

4949
expect(select).toHaveTextContent('Red');
5050
expect(formInstance.getFieldValue('test')).toBe('2');
@@ -60,10 +60,10 @@ describe('<Select />', () => {
6060
);
6161

6262
const select = getByRole('button');
63-
await act(async () => await userEvent.click(select));
63+
await userEvent.click(select);
6464

6565
const options = getAllByRole('option');
66-
await act(async () => await userEvent.click(options[1]));
66+
await userEvent.click(options[1]);
6767

6868
expect(select).toHaveTextContent('Red');
6969
expect(formInstance.getFieldValue('test')).toBe('2');

src/components/fields/Switch/switch.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('<Switch />', () => {
88
const { getByRole } = render(<Switch aria-label="test" />);
99
const switchElement = getByRole('switch');
1010

11-
await act(async () => await userEvent.click(switchElement));
11+
await userEvent.click(switchElement);
1212

1313
expect(switchElement).toBeChecked();
1414
});
@@ -22,7 +22,7 @@ describe('<Switch />', () => {
2222

2323
const switchElement = getByRole('switch');
2424

25-
await act(async () => await userEvent.click(switchElement));
25+
await userEvent.click(switchElement);
2626

2727
expect(switchElement).toBeChecked();
2828
expect(formInstance.getFieldValue('test')).toBe(true);
@@ -35,7 +35,7 @@ describe('<Switch />', () => {
3535

3636
const switchElement = getByRole('switch');
3737

38-
await act(async () => await userEvent.click(switchElement));
38+
await userEvent.click(switchElement);
3939

4040
expect(switchElement).toBeChecked();
4141
expect(formInstance.getFieldValue('test')).toBe(true);

src/components/fields/TextArea/textarea.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('<TextArea />', () => {
1010
const { getByRole } = render(<TextArea label="test" />);
1111
const input = getByRole('textbox');
1212

13-
await act(async () => await userEvent.type(input, 'Hello, World!'));
13+
await userEvent.type(input, 'Hello, World!');
1414

1515
expect(input).toHaveValue('Hello, World!');
1616
});
@@ -22,7 +22,7 @@ describe('<TextArea />', () => {
2222

2323
const input = getByRole('textbox');
2424

25-
await act(async () => await userEvent.type(input, 'Hello, World!'));
25+
await userEvent.type(input, 'Hello, World!');
2626

2727
expect(input).toHaveValue('Hello, World!');
2828
expect(formInstance.getFieldValue('test')).toEqual('Hello, World!');
@@ -37,7 +37,7 @@ describe('<TextArea />', () => {
3737

3838
const input = getByRole('textbox');
3939

40-
await act(async () => await userEvent.type(input, 'Hello, World!'));
40+
await userEvent.type(input, 'Hello, World!');
4141

4242
expect(input).toHaveValue('Hello, World!');
4343
expect(formInstance.getFieldValue('test')).toEqual('Hello, World!');

src/components/fields/TextInput/text-input.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('<TextInput />', () => {
99

1010
const input = getByRole('textbox');
1111

12-
await act(async () => await userEvent.type(input, 'Hello, World!'));
12+
await userEvent.type(input, 'Hello, World!');
1313

1414
expect(input).toHaveValue('Hello, World!');
1515
});
@@ -23,7 +23,7 @@ describe('<TextInput />', () => {
2323

2424
const input = getByRole('textbox');
2525

26-
await act(async () => await userEvent.type(input, 'Hello, World!'));
26+
await userEvent.type(input, 'Hello, World!');
2727

2828
expect(input).toHaveValue('Hello, World!');
2929
expect(formInstance.getFieldValue('test')).toEqual('Hello, World!');
@@ -36,7 +36,7 @@ describe('<TextInput />', () => {
3636

3737
const input = getByRole('textbox');
3838

39-
await act(async () => await userEvent.type(input, 'Hello, World!'));
39+
await userEvent.type(input, 'Hello, World!');
4040

4141
expect(input).toHaveValue('Hello, World!');
4242
expect(formInstance.getFieldValue('test')).toEqual('Hello, World!');

src/components/form/Form/submit-error.test.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ describe('<SubmitError />', () => {
2626
const submit = getByRole('button');
2727
const input = getByRole('textbox');
2828

29-
await act(async () => {
30-
await userEvents.type(input, 'test');
31-
await userEvents.click(submit);
32-
});
29+
await userEvents.type(input, 'test');
30+
await userEvents.click(submit);
3331

3432
await waitFor(() => {
3533
// onSubmitFailed callback should only be called if onSubmit callback is called and failed
@@ -63,10 +61,8 @@ describe('<SubmitError />', () => {
6361
const submit = getByRole('button');
6462
const input = getByRole('textbox');
6563

66-
await act(async () => {
67-
await userEvents.type(input, 'test');
68-
await userEvents.click(submit);
69-
});
64+
await userEvents.type(input, 'test');
65+
await userEvents.click(submit);
7066

7167
await waitFor(() => {
7268
// onSubmitFailed callback should only be called if onSubmit callback is called and failed
@@ -84,7 +80,7 @@ describe('<SubmitError />', () => {
8480
expect(submitErrorElement).toBeInTheDocument();
8581
});
8682

87-
await act(() => userEvents.type(input, 'changed'));
83+
await userEvents.type(input, 'changed');
8884

8985
await waitFor(() => {
9086
expect(submitErrorElement).not.toBeInTheDocument();
@@ -111,10 +107,8 @@ describe('<SubmitError />', () => {
111107
const submit = getByRole('button');
112108
const input = getByRole('textbox');
113109

114-
await act(async () => {
115-
await userEvents.type(input, 'test');
116-
await userEvents.click(submit);
117-
});
110+
await userEvents.type(input, 'test');
111+
await userEvents.click(submit);
118112

119113
await waitFor(() => {
120114
// onSubmitFailed callback should only be called if onSubmit callback is called and failed

src/components/form/Form/submit.test.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ describe('<Form />', () => {
4141
const submit = getByRole('button');
4242
const input = getByRole('textbox');
4343

44-
await act(async () => {
45-
await userEvents.type(input, 'test');
46-
});
44+
await userEvents.type(input, 'test');
4745

4846
await userEvents.click(submit);
4947

@@ -78,10 +76,8 @@ describe('<Form />', () => {
7876

7977
const input = getByRole('textbox');
8078

81-
await act(async () => {
82-
await userEvents.type(input, 'test');
83-
await expect(formInstance.submit()).rejects.toThrow('Custom Error');
84-
});
79+
await userEvents.type(input, 'test');
80+
await expect(formInstance.submit()).rejects.toThrow('Custom Error');
8581

8682
await expect(onSubmitFailed).toBeCalledTimes(1);
8783
await expect(onSubmit).toBeCalledTimes(1);

0 commit comments

Comments
 (0)