import { shallow, ShallowWrapper } from 'enzyme'; import { ServerForm } from '../../../src/servers/helpers/ServerForm'; import { FormGroupContainer } from '../../../src/utils/FormGroupContainer'; describe('', () => { let wrapper: ShallowWrapper; const onSubmit = jest.fn(); beforeEach(() => { wrapper = shallow(Something); }); afterEach(() => wrapper?.unmount()); afterEach(jest.resetAllMocks); it('renders components', () => { expect(wrapper.find(FormGroupContainer)).toHaveLength(3); expect(wrapper.find('span')).toHaveLength(1); }); it('invokes submit callback when submit event is triggered', () => { const form = wrapper.find('form'); const preventDefault = jest.fn(); form.simulate('submit', { preventDefault }); expect(preventDefault).toHaveBeenCalled(); expect(onSubmit).toHaveBeenCalled(); }); });