mirror of
https://github.com/fleetdm/fleet
synced 2026-05-18 06:28:40 +00:00
Fleet used significant resources storing the full network interface information for each host. This data was unused, except to get the IP and MAC of the primary interface. With these changes, only those pieces of data are stored. - Calculate and store primary IP and MAC - Remove transaction for storing full interfaces - Update targets search to use new IP and MAC columns - Update frontend to use new new columns
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
import React from 'react';
|
|
import expect, { createSpy, restoreSpies } from 'expect';
|
|
import { mount } from 'enzyme';
|
|
import { noop } from 'lodash';
|
|
|
|
import { hostStub, labelStub } from 'test/stubs';
|
|
import TargetOption from './TargetOption';
|
|
|
|
describe('TargetOption - component', () => {
|
|
afterEach(restoreSpies);
|
|
|
|
it('renders a label option for label targets', () => {
|
|
const count = 5;
|
|
const component = mount(<TargetOption onMoreInfoClick={noop} target={{ ...labelStub, count }} />);
|
|
expect(component.find('.is-label').length).toEqual(1);
|
|
expect(component.text()).toContain(`${count} hosts`);
|
|
});
|
|
|
|
it('renders a host option for host targets', () => {
|
|
const component = mount(<TargetOption onMoreInfoClick={noop} target={{ ...hostStub, platform: 'windows' }} />);
|
|
expect(component.find('.is-host').length).toEqual(1);
|
|
expect(component.find('i.kolidecon-windows').length).toEqual(1);
|
|
expect(component.text()).toContain(hostStub.primary_ip);
|
|
});
|
|
|
|
it('calls the onSelect prop when + icon button is clicked', () => {
|
|
const onSelectSpy = createSpy();
|
|
const component = mount(
|
|
<TargetOption
|
|
onMoreInfoClick={noop}
|
|
onSelect={onSelectSpy}
|
|
target={hostStub}
|
|
/>,
|
|
);
|
|
component.find('.target-option__add-btn').simulate('click');
|
|
expect(onSelectSpy).toHaveBeenCalled();
|
|
});
|
|
|
|
it('calls the onMoreInfoClick prop when the item content is clicked', () => {
|
|
const onMoreInfoClickSpy = createSpy();
|
|
const onMoreInfoClick = () => {
|
|
return onMoreInfoClickSpy;
|
|
};
|
|
const component = mount(
|
|
<TargetOption
|
|
onMoreInfoClick={onMoreInfoClick}
|
|
target={hostStub}
|
|
/>,
|
|
);
|
|
component.find('.target-option__target-content').simulate('click');
|
|
expect(onMoreInfoClickSpy).toHaveBeenCalled();
|
|
});
|
|
});
|