import { toBeCalled } from '@rws-air/utils'; import { shallow, ShallowWrapper } from 'enzyme'; import { Field, Formik } from 'formik'; import { createRef, FC } from 'react'; import { Checkbox } from './CheckBox'; const mockCheckboxOnChange = jest.fn(); const mockCheckboxOnBlur = jest.fn(); describe('Component Tests', () => { let checkBox: ShallowWrapper; beforeAll(() => { checkBox = shallow( ).find(Field); }); afterAll(() => { jest.clearAllMocks(); }); test('checkbox function called onChange', () => { const changeEvent = { event: { target: { value: true } } }; checkBox.simulate('change', changeEvent); toBeCalled(mockCheckboxOnChange, 1, changeEvent); }); }); describe('Snapshot Testing', () => { test('Required Props', () => { const checkBox = shallow( ); expect(checkBox).toMatchSnapshot(); }); test('Passing custom checked property', () => { const checkBox = shallow( ); expect(checkBox).toMatchSnapshot(); }); test('Passing a bunch of additional props', () => { const checkBox = shallow( ); expect(checkBox).toMatchSnapshot(); }); }); const BaseFormik: FC = ({ children }) => ( undefined}> {children} );