Skip to content

Commit

Permalink
Remove uniforms-semantic TextField enzyme test
Browse files Browse the repository at this point in the history
  • Loading branch information
kestarumper committed Feb 9, 2024
1 parent 0bdea39 commit 2aa385f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 288 deletions.
2 changes: 1 addition & 1 deletion packages/uniforms-bootstrap3/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('@RTL', () => {
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testTextField(theme.TextField, { testWrapClassName: true });
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
});
2 changes: 1 addition & 1 deletion packages/uniforms-bootstrap4/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('@RTL', () => {
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testTextField(theme.TextField, { testWrapClassName: true });
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
});
2 changes: 1 addition & 1 deletion packages/uniforms-bootstrap5/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('@RTL', () => {
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testTextField(theme.TextField, { testWrapClassName: true });
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
});
284 changes: 0 additions & 284 deletions packages/uniforms-semantic/__tests__/TextField.tsx

This file was deleted.

5 changes: 4 additions & 1 deletion packages/uniforms-semantic/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ describe('@RTL', () => {
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testTextField(theme.TextField, {
testWrapClassName: true,
testRenderIcon: true,
});
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
});
27 changes: 27 additions & 0 deletions packages/uniforms/__suites__/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type TestTextFieldOptions = {
props: PropsWithChildren<{ themeOptions: any }>,
) => JSX.Element;
};
testWrapClassName?: boolean;
testRenderIcon?: boolean;
};

export function testTextField(
Expand Down Expand Up @@ -285,4 +287,29 @@ export function testTextField(
expect(elements[0]).not.toHaveClass('MuiFormControl-fullWidth');
});
}

if (options.testRenderIcon) {
test('<TextField> - renders an icon', () => {
const { container } = renderWithZod({
element: <TextField name="x" icon="small home" />,
schema: z.object({ x: z.string() }),
});

expect(container.querySelector('i')).toBeInTheDocument();
});
}

if (options.testWrapClassName) {
test('<TextField> - renders with a custom wrapClassName', () => {
const testClassName = 'test-class-name';
renderWithZod({
element: <TextField name="x" wrapClassName={testClassName} />,
schema: z.object({ x: z.string() }),
});

expect(screen.getByRole('textbox').closest('div')).toHaveClass(
testClassName,
);
});
}
}

0 comments on commit 2aa385f

Please sign in to comment.