Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed May 26, 2020
1 parent 4e20369 commit 99cf44a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CursorDirection,
SortOrder,
} from '../../../../../common/runtime_types';
import { MonitorListComponent } from '../monitor_list';
import { MonitorListComponent, noItemsMessage } from '../monitor_list';
import { renderWithRouter, shallowWithRouter } from '../../../../lib';
import * as redux from 'react-redux';

Expand Down Expand Up @@ -288,4 +288,24 @@ describe('MonitorList component', () => {
expect(component).toMatchSnapshot();
});
});

describe('noItemsMessage', () => {
it('returns loading message while loading', () => {
expect(noItemsMessage(true)).toEqual(`Loading...`);
});

it('returns loading message when filters are defined and loading', () => {
expect(noItemsMessage(true, 'filters')).toEqual(`Loading...`);
});

it('returns no monitors selected when filters are defined and not loading', () => {
expect(noItemsMessage(false, 'filters')).toEqual(
`No monitors found for selected filter criteria`
);
});

it('returns no data message when no filters and not loading', () => {
expect(noItemsMessage(false)).toEqual(`No uptime monitors found`);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const TruncatedEuiLink = styled(EuiLink)`
text-overflow: ellipsis;
`;

const noItemsMessage = (loading: boolean, filters?: string) => {
export const noItemsMessage = (loading: boolean, filters?: string) => {
if (loading) return labels.LOADING;
return !!filters ? labels.NO_MONITOR_ITEM_SELECTED : labels.NO_DATA_MESSAGE;
};
Expand Down

0 comments on commit 99cf44a

Please sign in to comment.