|
1 | 1 | /** |
2 | 2 | * @jest-environment jsdom |
3 | 3 | */ |
4 | | -import * as React from 'react' |
5 | | -import { render, fireEvent, waitFor } from '@testing-library/react' |
| 4 | +import React from 'react' |
| 5 | +import { render, cleanup, act } from '@testing-library/react' |
6 | 6 | import '@testing-library/jest-dom' |
7 | 7 | import Form from './ReactFinalForm' |
8 | 8 | import Field from './Field' |
9 | | -import { act } from 'react-dom/test-utils' |
10 | 9 |
|
11 | 10 | describe('useField - Dynamic Name (Issue #869)', () => { |
12 | | - it('should keep name and value in sync when field name changes', async () => { |
| 11 | + afterEach(cleanup) |
| 12 | + |
| 13 | + it('should keep name and value in sync when field name changes', () => { |
13 | 14 | const renderSpy = jest.fn() |
14 | 15 |
|
15 | | - const TestComponent = ({ fieldName }: { fieldName: string }) => { |
| 16 | + const TestComponent = ({ fieldName }) => { |
16 | 17 | return ( |
17 | 18 | <Form |
18 | 19 | onSubmit={() => {}} |
@@ -59,8 +60,8 @@ describe('useField - Dynamic Name (Issue #869)', () => { |
59 | 60 | }) |
60 | 61 | }) |
61 | 62 |
|
62 | | - it('should have correct value immediately after name change (no stale renders)', async () => { |
63 | | - const TestComponent = ({ fieldName }: { fieldName: string }) => { |
| 63 | + it('should have correct value immediately after name change (no stale renders)', () => { |
| 64 | + const TestComponent = ({ fieldName }) => { |
64 | 65 | return ( |
65 | 66 | <Form |
66 | 67 | onSubmit={() => {}} |
|
0 commit comments