diff --git a/packages/uniforms-mui/__tests__/NestField.tsx b/packages/uniforms-mui/__tests__/NestField.tsx index 466d28e65..0bcc48fec 100644 --- a/packages/uniforms-mui/__tests__/NestField.tsx +++ b/packages/uniforms-mui/__tests__/NestField.tsx @@ -1,36 +1,37 @@ -import FormHelperText from '@mui/material/FormHelperText'; -import FormLabel from '@mui/material/FormLabel'; +import { screen } from '@testing-library/react'; import React from 'react'; import { NestField } from 'uniforms-mui'; +import { renderWithZod } from 'uniforms/__suites__'; +import { z } from 'zod'; -import createContext from './_createContext'; -import mount from './_mount'; +describe('@RTL - NestField tests', () => { + test(' - renders a label (required annotation)', () => { + const { container } = renderWithZod({ + element: , + schema: z.object({ + x: z.object({ + a: z.string(), + b: z.number(), + }), + }), + }); -test(' - renders a Subheader', () => { - const element = ; - const wrapper = mount( - element, - createContext({ - x: { type: Object }, - 'x.a': { type: String }, - 'x.b': { type: Number }, - }), - ); + const label = container.getElementsByTagName('legend')[0]?.textContent; - expect(wrapper.find(FormLabel).at(0).text()).toBe('y *'); -}); + expect(label).toBe('y *'); + }); -test(' - renders a helperText', () => { - const element = ; - const wrapper = mount( - element, - createContext({ - x: { type: Object }, - 'x.a': { type: String }, - 'x.b': { type: Number }, - }), - ); + test(' - renders a helperText', () => { + renderWithZod({ + element: , + schema: z.object({ + x: z.object({ + a: z.string(), + b: z.number(), + }), + }), + }); - expect(wrapper.find(FormHelperText)).toHaveLength(1); - expect(wrapper.find(FormHelperText).text()).toBe('Helper'); + expect(screen.getByText('Helper')).toBeInTheDocument(); + }); });