fleet/frontend/components/hosts/HostContainer/HostContainer.tests.jsx
noahtalerman 5dd9b75e9c
Update query page (edit, new, manage) and packs page (edit, new, manage) styles. (#106)
The goal of this PR is to update the style across the query and packs pages so they are consistent with the latest global styles (colors, buttons, and fonts).
2020-12-08 12:07:54 -08:00

54 lines
1.8 KiB
JavaScript

import React from 'react';
import { noop } from 'lodash';
import { mount } from 'enzyme';
import { hostStub } from 'test/stubs';
import HostContainer from './HostContainer';
const allHostsLabel = { id: 1, display_text: 'All Hosts', slug: 'all-hosts', type: 'all', count: 22 };
const customLabel = { id: 6, display_text: 'Custom Label', slug: 'custom-label', type: 'custom', count: 3 };
describe('HostsContainer - component', () => {
const props = {
hosts: [hostStub],
selectedLabel: allHostsLabel,
loadingHosts: false,
displayType: 'Grid',
toggleAddHostModal: noop,
toggleDeleteHostModal: noop,
onQueryHost: noop,
};
it('renders Spinner while hosts are loading', () => {
const loadingProps = { ...props, loadingHosts: true };
const page = mount(<HostContainer {...loadingProps} hosts={[]} selectedLabel={allHostsLabel} />);
expect(page.find('Spinner').length).toEqual(1);
});
it('displays getting started text if no hosts available', () => {
const page = mount(<HostContainer {...props} hosts={[]} selectedLabel={allHostsLabel} />);
expect(page.find('h2').text()).toEqual('Get started adding hosts to Fleet.');
});
it('renders message if no hosts available and not on All Hosts', () => {
const page = mount(<HostContainer {...props} hosts={[]} selectedLabel={customLabel} />);
expect(page.find('.host-container--no-hosts').length).toEqual(1);
});
it('renders hosts as HostsTable', () => {
const page = mount(<HostContainer {...props} />);
expect(page.find('HostsTable').length).toEqual(1);
});
it('does not render sidebar if labels are loading', () => {
const loadingProps = { ...props, loadingLabels: true };
const page = mount(<HostContainer {...loadingProps} hosts={[]} selectedLabel={allHostsLabel} />);
expect(page.find('HostSidePanel').length).toEqual(0);
});
});