-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Migrated
ListItemField
tests to @testing-library/react (#1304)
Co-authored-by: Piotr Pośpiech <[email protected]>
1 parent
9ae8eb5
commit eed59c6
Showing
18 changed files
with
49 additions
and
416 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { screen } from '@testing-library/react'; | ||
import React, { ComponentType } from 'react'; | ||
import z from 'zod'; | ||
|
||
import { renderWithZod } from './render-zod'; | ||
|
||
export function testListItemField(ListItemField: ComponentType<any>) { | ||
test('<ListItemField> - works', () => { | ||
renderWithZod({ | ||
element: <ListItemField name="field" />, | ||
schema: z.object({ field: z.string().optional() }), | ||
}); | ||
|
||
expect(screen.getByLabelText('Field')).toBeInTheDocument(); | ||
}); | ||
|
||
test('<ListItemField> - renders ListDelField', () => { | ||
renderWithZod({ | ||
element: <ListItemField name="field" />, | ||
schema: z.object({ field: z.string() }), | ||
}); | ||
|
||
expect(screen.getByRole('button')).toBeInTheDocument(); | ||
}); | ||
|
||
test('<ListItemField> - renders children if specified', () => { | ||
const Child = jest.fn(() => <div />) as React.FC<any>; | ||
|
||
renderWithZod({ | ||
element: ( | ||
<ListItemField name="field"> | ||
<Child /> | ||
</ListItemField> | ||
), | ||
schema: z.object({ field: z.string() }), | ||
}); | ||
|
||
expect(Child).toHaveBeenCalledTimes(1); | ||
}); | ||
} |
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