mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-05-09 13:10:19 +03:00
Migrated to TS all servers helpers
This commit is contained in:
parent
8cc0695ee9
commit
aee4c2d02f
14 changed files with 129 additions and 137 deletions
test/servers/helpers
31
test/servers/helpers/ServerForm.test.tsx
Normal file
31
test/servers/helpers/ServerForm.test.tsx
Normal file
|
@ -0,0 +1,31 @@
|
|||
import React from 'react';
|
||||
import { shallow, ShallowWrapper } from 'enzyme';
|
||||
import { ServerForm } from '../../../src/servers/helpers/ServerForm';
|
||||
import { HorizontalFormGroup } from '../../../src/utils/HorizontalFormGroup';
|
||||
|
||||
describe('<ServerForm />', () => {
|
||||
let wrapper: ShallowWrapper;
|
||||
const onSubmit = jest.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<ServerForm onSubmit={onSubmit}><span>Something</span></ServerForm>);
|
||||
});
|
||||
|
||||
afterEach(() => wrapper?.unmount());
|
||||
afterEach(jest.resetAllMocks);
|
||||
|
||||
it('renders components', () => {
|
||||
expect(wrapper.find(HorizontalFormGroup)).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();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue