938 pack query inspector (#1177)
* API client for patching a scheduled query * Change select to check on ScheduledQueriesLists * Clicking a scheduled query list item selects the scheduled query * Helpers to format scheduled queries for client/server * Allow updating a scheduled query * Form cancel button
This commit is contained in:
@@ -5,6 +5,7 @@ import { noop } from 'lodash';
|
||||
|
||||
import ConfigurePackQueryForm from 'components/forms/ConfigurePackQueryForm';
|
||||
import { itBehavesLikeAFormDropdownElement, itBehavesLikeAFormInputElement } from 'test/helpers';
|
||||
import { scheduledQueryStub } from 'test/stubs';
|
||||
|
||||
describe('ConfigurePackQueryForm - component', () => {
|
||||
afterEach(restoreSpies);
|
||||
@@ -53,4 +54,43 @@ describe('ConfigurePackQueryForm - component', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('cancelling the form', () => {
|
||||
const CancelButton = form => form.find('.configure-pack-query-form__cancel-btn');
|
||||
|
||||
it('displays a cancel Button when updating a scheduled query', () => {
|
||||
const NewScheduledQueryForm = mount(
|
||||
<ConfigurePackQueryForm
|
||||
formData={{ query_id: 1 }}
|
||||
handleSubmit={noop}
|
||||
onCancel={noop}
|
||||
/>
|
||||
);
|
||||
const UpdateScheduledQueryForm = mount(
|
||||
<ConfigurePackQueryForm
|
||||
formData={scheduledQueryStub}
|
||||
handleSubmit={noop}
|
||||
onCancel={noop}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(CancelButton(NewScheduledQueryForm).length).toEqual(0);
|
||||
expect(CancelButton(UpdateScheduledQueryForm).length).toEqual(1);
|
||||
});
|
||||
|
||||
it('calls the onCancel prop when the cancel Button is clicked', () => {
|
||||
const spy = createSpy();
|
||||
const UpdateScheduledQueryForm = mount(
|
||||
<ConfigurePackQueryForm
|
||||
formData={scheduledQueryStub}
|
||||
handleSubmit={noop}
|
||||
onCancel={spy}
|
||||
/>
|
||||
);
|
||||
|
||||
CancelButton(UpdateScheduledQueryForm).simulate('click');
|
||||
|
||||
expect(spy).toHaveBeenCalledWith(scheduledQueryStub);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user