Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import Status from '../Status';
import { HOST_STATUSES_KEY } from '../HostStatusesConstants';
import { store } from '../HostStatuses.fixtures.js'
import { testComponentSnapshotsWithFixtures } from '../../../common/testHelpers';

jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
Expand Down Expand Up @@ -51,9 +53,36 @@ jest.mock('../HostStatusesSelectors.js', () => {
}
});

const fixtures = {
'renders Status': { name: store.API[HOST_STATUSES_KEY].response.results[0].name },
};
const { name } = store.API[HOST_STATUSES_KEY].response.results[0];

describe('Status', () => {
testComponentSnapshotsWithFixtures(Status, fixtures);
it('renders Status', () => {
render(<Status name={name} />);

// status name and description
expect(screen.getByText('Status Name')).toBeInTheDocument();
expect(screen.getByText('Description of the status')).toBeInTheDocument();

// ok/warn/error totals and owned counts
expect(screen.getByText('Total: 3')).toBeInTheDocument();
expect(screen.getByText('Owned: 1')).toBeInTheDocument();
expect(screen.getByText('Total: 7')).toBeInTheDocument();
expect(screen.getByText('Owned: 2')).toBeInTheDocument();
expect(screen.getByText('Total: 5')).toBeInTheDocument();
expect(screen.getByText('Owned: 0')).toBeInTheDocument();

// totals link to their status searches
expect(screen.getByRole('link', { name: 'Total: 3' })).toHaveAttribute(
'href',
'/hosts?search=status+%3D+ok'
);
expect(screen.getByRole('link', { name: 'Total: 7' })).toHaveAttribute(
'href',
'/hosts?search=status+%3D+warn'
);
expect(screen.getByRole('link', { name: 'Total: 5' })).toHaveAttribute(
'href',
'/hosts?search=status+%3D+error'
);
});
});

This file was deleted.

Loading