Skip to content

Commit

Permalink
Fix rendering of query type icons for imported yaml packs (kolide#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
zwass authored Aug 1, 2019
1 parent 3b50bf0 commit d64e84f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class ScheduledQueriesListItem extends Component {
return 'camera';
}

if (removed) {
// Default is differential with removals, so we treat null as removed = true
if (removed !== false) {
return 'plus-minus';
}

Expand Down Expand Up @@ -103,4 +104,3 @@ class ScheduledQueriesListItem extends Component {
}

export default ScheduledQueriesListItem;

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import expect, { createSpy, restoreSpies } from 'expect';
import { mount } from 'enzyme';
import { mount, shallow } from 'enzyme';
import { noop } from 'lodash';

import { scheduledQueryStub } from 'test/stubs';
Expand Down Expand Up @@ -34,7 +34,7 @@ describe('ScheduledQueriesListItem - component', () => {
});

it('renders a Checkbox component', () => {
const component = mount(<ScheduledQueriesListItem {...defaultProps} />);
const component = shallow(<ScheduledQueriesListItem {...defaultProps} />);
expect(component.find('Checkbox').length).toEqual(1);
});

Expand All @@ -52,7 +52,7 @@ describe('ScheduledQueriesListItem - component', () => {
it('calls the onSelect prop when a list item is selected', () => {
const spy = createSpy();
const props = { ...defaultProps, onSelect: spy };
const component = mount(<ScheduledQueriesListItem {...props} />);
const component = shallow(<ScheduledQueriesListItem {...props} />);
const tableRow = component.find('ClickableTableRow');

tableRow.simulate('click');
Expand All @@ -63,11 +63,39 @@ describe('ScheduledQueriesListItem - component', () => {
it('calls the onDblClick prop when a list item is double clicked', () => {
const spy = createSpy();
const props = { ...defaultProps, onDblClick: spy };
const component = mount(<ScheduledQueriesListItem {...props} />);
const component = shallow(<ScheduledQueriesListItem {...props} />);
const tableRow = component.find('ClickableTableRow');

tableRow.simulate('doubleclick');

expect(spy).toHaveBeenCalledWith(scheduledQueryStub.query_id);
});

describe('renders the appropriate query type icon', () => {
const query = { ...scheduledQueryStub, removed: null };
const props = { ...defaultProps, scheduledQuery: query };
let component = shallow(<ScheduledQueriesListItem {...props} />);

expect(component.find('Icon').last().props().name).toEqual('camera');

query.snapshot = false;
query.removed = false;
component = shallow(<ScheduledQueriesListItem {...props} />);
expect(component.find('Icon').last().props().name).toEqual('bold-plus');

query.snapshot = false;
query.removed = null;
component = shallow(<ScheduledQueriesListItem {...props} />);
expect(component.find('Icon').last().props().name).toEqual('plus-minus');

query.snapshot = false;
query.removed = true;
component = shallow(<ScheduledQueriesListItem {...props} />);
expect(component.find('Icon').last().props().name).toEqual('plus-minus');

query.snapshot = null;
query.removed = true;
component = shallow(<ScheduledQueriesListItem {...props} />);
expect(component.find('Icon').last().props().name).toEqual('plus-minus');
});
});

0 comments on commit d64e84f

Please sign in to comment.