-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix (FormItem): fix multi select error never shown
- Loading branch information
1 parent
0934b61
commit 11269b2
Showing
3 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import '@testing-library/jest-dom/extend-expect' | ||
import React from 'react' | ||
import { Formik } from 'formik' | ||
import { render, fireEvent, waitForDomChange } from '@testing-library/react' | ||
import Form from '../form/form' | ||
import Input from '../input' | ||
import { act } from 'react-dom/test-utils' | ||
|
||
const Container = ({ fast }: { fast: boolean }) => { | ||
return ( | ||
<Formik initialValues={{ field: 'initial value' }} onSubmit={() => {}}> | ||
<Form> | ||
<Input data-testid='uat' name='field' fast={fast} /> | ||
</Form> | ||
</Formik> | ||
) | ||
} | ||
|
||
describe('test initial value', () => { | ||
it.each` | ||
fast | ||
${true} | ||
${false} | ||
`('should display initial value (fast=$fast)', async (fast: boolean) => { | ||
const { findByTestId } = render(<Container fast={fast} />) | ||
expect(await findByTestId('uat')).toHaveValue('initial value') | ||
}) | ||
}) | ||
|
||
describe('should change', () => { | ||
it.each` | ||
fast | ||
${true} | ||
${false} | ||
`('should change (fast=$fast)', async (fast: boolean) => { | ||
const { findByTestId } = render(<Container fast={fast} />) | ||
const uat = await findByTestId('uat') | ||
await act(async () => { | ||
fireEvent.change(uat, { target: { value: 'new value' } }) | ||
await waitForDomChange() | ||
}) | ||
expect(await findByTestId('uat')).toHaveValue('new value') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters