import * as React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { CheckboxField } from '../Checkbox'; import render from '../../utils/_tests/render'; describe('props', () => { it('should render correctly', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should assign a ref via checkboxRef', () => { const ref = React.createRef(); render(); expect(ref.current).toMatchSnapshot(); }); it('should render correctly with CSS props', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with checked', () => { const { container } = render( {}} />); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with defaultChecked', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with disabled', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with indeterminate', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with isRequired', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with label', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with a checkboxLabel', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with name', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); ['success', 'danger', 'warning'].forEach((state) => { it(`should render correctly for ${state} state`, () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); }); it('should render correctly with value', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); }); describe('composition', () => { describe('as', () => { it('should render correctly', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); }); describe('hook', () => { it('should return with CheckboxField props', () => { const { result } = renderHook(() => CheckboxField.useProps()); expect(result.current).toMatchSnapshot(); }); }); describe('render props', () => { it('should render correctly', () => { const { container } = render( {(CheckboxFieldProps) =>
Hello world
}
); expect(container.firstChild).toMatchSnapshot(); }); }); }); describe('overrides', () => { it('CheckboxField.base should render correctly', () => { const { container } = render( ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('theming', () => { it('CheckboxField.base should render correctly', () => { const { container } = render(, { // @ts-ignore theme: { CheckboxField: { styles: { base: { backgroundColor: 'red' } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); }); describe('defaultProps', () => { it('should render correctly for className', () => { const { container } = render(, { // @ts-ignore theme: { CheckboxField: { defaultProps: { className: 'test', color: 'primary' } } }, }); expect(container.firstChild).toMatchSnapshot(); }); });