fleet/frontend/components/side_panels/QueryDetailsSidePanel/QueryDetailsSidePanel.tests.jsx
Mike Stone 39c9c6b0da Manage queries page (#762)
* renders ManageQueriesPage at /queries/manage

* Renames QueriesList components to ScheduledQueriesList components

* creates QueriesList component

* Adds side panel component to display query details

* Adds KolideAce editor to Query Details side panel

* Handle Edit Query button click

* Change text of the Delete Query button

* Show confirmation modal before deleting queries
2017-01-06 15:57:44 -05:00

37 lines
1.2 KiB
JavaScript

import React from 'react';
import expect, { createSpy, restoreSpies } from 'expect';
import { mount } from 'enzyme';
import { noop } from 'lodash';
import QueryDetailsSidePanel from 'components/side_panels/QueryDetailsSidePanel';
import { queryStub } from 'test/stubs';
describe('QueryDetailsSidePanel - component', () => {
afterEach(restoreSpies);
it('renders', () => {
const component = mount(<QueryDetailsSidePanel onEditQuery={noop} query={queryStub} />);
expect(component.length).toEqual(1);
});
it('renders a read-only Kolide Ace component with the query text', () => {
const component = mount(<QueryDetailsSidePanel onEditQuery={noop} query={queryStub} />);
const aceEditor = component.find('KolideAce');
expect(aceEditor.length).toEqual(1);
expect(aceEditor.prop('value')).toEqual(queryStub.query);
expect(aceEditor.prop('readOnly')).toEqual(true);
});
it('calls the onEditQuery prop when Edit/Run Query is clicked', () => {
const spy = createSpy();
const component = mount(<QueryDetailsSidePanel onEditQuery={spy} query={queryStub} />);
const button = component.find('Button');
button.simulate('click');
expect(spy).toHaveBeenCalledWith(queryStub);
});
});