mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-05-03 10:13:01 +03:00
Created common component that can be used both for create and edit servers
This commit is contained in:
parent
fb0ebddf28
commit
6d44ac1e0c
4 changed files with 93 additions and 33 deletions
test/servers/helpers
33
test/servers/helpers/ServerForm.test.js
Normal file
33
test/servers/helpers/ServerForm.test.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { ServerForm } from '../../../src/servers/helpers/ServerForm';
|
||||
import { HorizontalFormGroup } from '../../../src/utils/HorizontalFormGroup';
|
||||
|
||||
describe('<ServerForm />', () => {
|
||||
let wrapper;
|
||||
const onSubmit = jest.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<ServerForm onSubmit={onSubmit}><span>Something</span></ServerForm>);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
wrapper && wrapper.unmount();
|
||||
});
|
||||
|
||||
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