diff --git a/src/utils/Result.tsx b/src/utils/Result.tsx index eacf40f0..e32872a8 100644 --- a/src/utils/Result.tsx +++ b/src/utils/Result.tsx @@ -15,6 +15,7 @@ export const Result: FC = ({ children, type, className, small = fal
', () => { - let wrapper: ShallowWrapper; - const createWrapper = (props: ResultProps) => { - wrapper = shallow(); - - return wrapper; - }; - - afterEach(() => wrapper?.unmount()); + const setUp = (props: ResultProps) => render(); it.each([ ['success' as ResultType, 'bg-main text-white'], ['error' as ResultType, 'bg-danger text-white'], ['warning' as ResultType, 'bg-warning'], ])('renders expected classes based on type', (type, expectedClasses) => { - const wrapper = createWrapper({ type }); - const innerCard = wrapper.find(SimpleCard); - - expect(innerCard.prop('className')).toEqual(`text-center ${expectedClasses}`); + setUp({ type }); + expect(screen.getByRole('document')).toHaveClass(expectedClasses); }); it.each([ - [undefined], ['foo'], ['bar'], ])('renders provided classes in root element', (className) => { - const wrapper = createWrapper({ type: 'success', className }); - - expect(wrapper.prop('className')).toEqual(className); + const { container } = setUp({ type: 'success', className }); + expect(container.firstChild).toHaveClass(className); }); it.each([{ small: true }, { small: false }])('renders small results properly', ({ small }) => { - const wrapper = createWrapper({ type: 'success', small }); - const bigElement = wrapper.find('.col-md-10'); - const smallElement = wrapper.find('.col-12'); - const innerCard = wrapper.find(SimpleCard); + const { container } = setUp({ type: 'success', small }); + const bigElement = container.querySelectorAll('.col-md-10'); + const smallElement = container.querySelectorAll('.col-12'); expect(bigElement).toHaveLength(small ? 0 : 1); expect(smallElement).toHaveLength(small ? 1 : 0); - expect(innerCard.prop('bodyClassName')).toEqual(small ? 'p-2' : ''); }); });