2016-12-21 17:25:54 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
import expect, { createSpy, restoreSpies } from 'expect';
|
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
|
import { noop } from 'lodash';
|
|
|
|
|
|
|
|
|
|
import ConfigurePackQueryForm from 'components/forms/ConfigurePackQueryForm';
|
|
|
|
|
import { itBehavesLikeAFormDropdownElement, itBehavesLikeAFormInputElement } from 'test/helpers';
|
|
|
|
|
|
|
|
|
|
describe('ConfigurePackQueryForm - component', () => {
|
|
|
|
|
afterEach(restoreSpies);
|
|
|
|
|
|
|
|
|
|
describe('form fields', () => {
|
|
|
|
|
const form = mount(
|
|
|
|
|
<ConfigurePackQueryForm
|
|
|
|
|
handleSubmit={noop}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
it('updates form state', () => {
|
|
|
|
|
itBehavesLikeAFormInputElement(form, 'interval');
|
|
|
|
|
itBehavesLikeAFormDropdownElement(form, 'logging_type');
|
|
|
|
|
itBehavesLikeAFormDropdownElement(form, 'platform');
|
|
|
|
|
itBehavesLikeAFormDropdownElement(form, 'version');
|
2017-02-01 20:48:08 +00:00
|
|
|
itBehavesLikeAFormInputElement(form, 'shard');
|
2016-12-21 17:25:54 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('submitting the form', () => {
|
|
|
|
|
const spy = createSpy();
|
|
|
|
|
const form = mount(
|
|
|
|
|
<ConfigurePackQueryForm
|
|
|
|
|
handleSubmit={spy}
|
|
|
|
|
formData={{ query_id: 1 }}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
it('submits the form with the form data', () => {
|
|
|
|
|
itBehavesLikeAFormInputElement(form, 'interval', 'InputField', 123);
|
|
|
|
|
itBehavesLikeAFormDropdownElement(form, 'logging_type');
|
|
|
|
|
itBehavesLikeAFormDropdownElement(form, 'platform');
|
|
|
|
|
itBehavesLikeAFormDropdownElement(form, 'version');
|
2017-02-01 20:48:08 +00:00
|
|
|
itBehavesLikeAFormInputElement(form, 'shard', 'InputField', 12);
|
2016-12-21 17:25:54 +00:00
|
|
|
|
|
|
|
|
form.find('form').simulate('submit');
|
|
|
|
|
|
|
|
|
|
expect(spy).toHaveBeenCalledWith({
|
|
|
|
|
interval: 123,
|
|
|
|
|
logging_type: 'differential',
|
2017-02-07 18:37:41 +00:00
|
|
|
platform: '',
|
2016-12-21 17:25:54 +00:00
|
|
|
query_id: 1,
|
2017-01-10 22:27:52 +00:00
|
|
|
version: '',
|
2017-02-01 20:48:08 +00:00
|
|
|
shard: 12,
|
2016-12-21 17:25:54 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|