-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved a few tests into AntD and MUI packages
- Loading branch information
Showing
6 changed files
with
121 additions
and
111 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,58 @@ | ||
import { screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { wrapField } from 'uniforms-antd'; | ||
import { renderWithZod } from 'uniforms/__suites__'; | ||
import { z } from 'zod'; | ||
|
||
describe('wrapField tests', () => { | ||
test('<wrapField> - renders wrapper with extra style', () => { | ||
renderWithZod({ | ||
element: wrapField( | ||
{ wrapperStyle: { backgroundColor: 'red' } }, | ||
<div data-testid="x" />, | ||
), | ||
schema: z.object({}), | ||
}); | ||
expect( | ||
screen.getByTestId('x').closest('.ant-form-item')?.getAttribute('style'), | ||
).toBe('background-color: red;'); | ||
}); | ||
|
||
test('<wrapField> - renders wrapper with an error status (error)', () => { | ||
const error = new Error(); | ||
renderWithZod({ | ||
element: wrapField({ error }, <div data-testid="x" />), | ||
schema: z.object({}), | ||
}); | ||
expect( | ||
screen | ||
.getByTestId('x') | ||
.closest('.ant-form-item-has-feedback.ant-form-item-has-error'), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
test('<wrapField> - renders wrapper with label and info', () => { | ||
renderWithZod({ | ||
element: wrapField({ label: 'Label', info: 'Info' }, <div />), | ||
schema: z.object({}), | ||
}); | ||
expect(screen.getByRole('img').getAttribute('aria-label')).toBe( | ||
'question-circle', | ||
); | ||
}); | ||
|
||
test('<wrapField> - renders wrapper with a custom validateStatus', () => { | ||
renderWithZod({ | ||
element: wrapField( | ||
{ validateStatus: 'success' }, | ||
<div data-testid="x" />, | ||
), | ||
schema: z.object({}), | ||
}); | ||
expect( | ||
screen | ||
.getByTestId('x') | ||
.closest('.ant-form-item-has-feedback.ant-form-item-has-success'), | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
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,20 @@ | ||
import { screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { wrapField } from 'uniforms-bootstrap4'; | ||
import { renderWithZod } from 'uniforms/__suites__'; | ||
import { z } from 'zod'; | ||
|
||
describe('wrapField tests', () => { | ||
test('<wrapField> - renders wrapper with correct class', () => { | ||
renderWithZod({ | ||
element: wrapField( | ||
{ wrapClassName: 'container' }, | ||
<div data-testid="x" />, | ||
), | ||
schema: z.object({}), | ||
}); | ||
expect( | ||
screen.getByTestId('x').parentElement?.classList.contains('container'), | ||
).toBe(true); | ||
}); | ||
}); |
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,20 @@ | ||
import { screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { wrapField } from 'uniforms-bootstrap5'; | ||
import { renderWithZod } from 'uniforms/__suites__'; | ||
import { z } from 'zod'; | ||
|
||
describe('wrapField tests', () => { | ||
test('<wrapField> - renders wrapper with correct class', () => { | ||
renderWithZod({ | ||
element: wrapField( | ||
{ wrapClassName: 'container' }, | ||
<div data-testid="x" />, | ||
), | ||
schema: z.object({}), | ||
}); | ||
expect( | ||
screen.getByTestId('x').parentElement?.classList.contains('container'), | ||
).toBe(true); | ||
}); | ||
}); |
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,19 @@ | ||
import { screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { wrapField } from 'uniforms-mui'; | ||
import { renderWithZod } from 'uniforms/__suites__'; | ||
import { z } from 'zod'; | ||
|
||
describe('wrapField tests', () => { | ||
test('<wrapField> - renders wrapper', () => { | ||
renderWithZod({ | ||
element: wrapField({}, <div data-testid="x" />), | ||
schema: z.object({}), | ||
}); | ||
expect( | ||
screen | ||
.getByTestId('x') | ||
.parentElement?.classList.contains('MuiFormControl-root'), | ||
).toBe(true); | ||
}); | ||
}); |
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