2016-10-11 15:32:39 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
import { mount } from 'enzyme';
|
2016-10-19 20:22:18 +00:00
|
|
|
|
2020-07-07 16:47:50 +00:00
|
|
|
import { stubbedOsqueryTable } from 'test/helpers';
|
|
|
|
|
|
2016-10-11 15:32:39 +00:00
|
|
|
import QuerySidePanel from './QuerySidePanel';
|
|
|
|
|
|
|
|
|
|
describe('QuerySidePanel - component', () => {
|
2020-12-01 18:15:12 +00:00
|
|
|
const onOsqueryTableSelect = jest.fn();
|
|
|
|
|
const onTextEditorInputChange = jest.fn();
|
2016-10-11 15:32:39 +00:00
|
|
|
const props = {
|
|
|
|
|
onOsqueryTableSelect,
|
|
|
|
|
onTextEditorInputChange,
|
2020-07-07 16:47:50 +00:00
|
|
|
selectedOsqueryTable: stubbedOsqueryTable,
|
2016-10-11 15:32:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
it('renders the selected table in the dropdown', () => {
|
|
|
|
|
const component = mount(<QuerySidePanel {...props} />);
|
2016-11-09 14:26:15 +00:00
|
|
|
const tableSelect = component.find('Dropdown');
|
2016-10-11 15:32:39 +00:00
|
|
|
|
|
|
|
|
expect(tableSelect.prop('value')).toEqual('users');
|
|
|
|
|
});
|
|
|
|
|
|
2020-12-01 18:15:12 +00:00
|
|
|
it(
|
|
|
|
|
'calls the onOsqueryTableSelect prop when a new table is selected in the dropdown',
|
|
|
|
|
() => {
|
|
|
|
|
const component = mount(<QuerySidePanel {...props} />);
|
|
|
|
|
component.instance().onSelectTable('groups');
|
2016-10-11 15:32:39 +00:00
|
|
|
|
2020-12-01 18:15:12 +00:00
|
|
|
expect(onOsqueryTableSelect).toHaveBeenCalledWith('groups');
|
|
|
|
|
},
|
|
|
|
|
);
|
2016-10-11 15:32:39 +00:00
|
|
|
});
|