Skip to content

Commit

Permalink
tested fitted class name
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrpospiech committed Jun 16, 2023
1 parent 26a999f commit db7fb59
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/uniforms-semantic/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('@RTL', () => {
});
suites.testAutoForm(theme.AutoForm);
suites.testBaseForm(theme.BaseForm);
suites.testBoolField(theme.BoolField, { testError: true });
suites.testBoolField(theme.BoolField, { testError: true, testFitted: true });
suites.testDateField(theme.DateField);
suites.testErrorField(theme.ErrorField);
suites.testErrorsField(theme.ErrorsField);
Expand Down
17 changes: 15 additions & 2 deletions packages/uniforms/__suites__/BoolField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { skipTestIf } from './skipTestIf';
export function testBoolField(
BoolField: ComponentType<any>,
options?: {
isButton?: boolean;
testCheckbox?: boolean;
testError?: boolean;
testSwitch?: boolean;
isButton?: boolean;
testFitted?: boolean;
testInline?: boolean;
testMUIThemeProps?: boolean;
testSwitch?: boolean;
},
) {
test('<BoolField> - renders an input', () => {
Expand Down Expand Up @@ -392,6 +393,18 @@ export function testBoolField(
expect(screen.getByText(/BoolFieldLabel.*/)).toBeInTheDocument();
});

skipTestIf(!options?.testFitted)(
'<BoolField> - renders with a `fitted` className when `label` is disabled',
() => {
const screen = renderWithZod({
element: <BoolField name="x" data-testid="boolfield" label="" />,
schema: z.object({ x: z.boolean() }),
});

expect(screen.container.querySelector('.ui')).toHaveClass('fitted');
},
);

skipTestIf(!options?.testCheckbox)(
'<BoolField> - renders a checkbox with correct label (specified)',
() => {
Expand Down

0 comments on commit db7fb59

Please sign in to comment.