Signed-off-by: Bernard Setz <bernard.setz@portainer.io> Co-authored-by: bernard-portainer <bernard.setz@portainer.io> Co-authored-by: Ali <83188384+testA113@users.noreply.github.com> Co-authored-by: Yajith Dayarathna <yajith.dayarathna@portainer.io> Co-authored-by: Chaim Lev-Ari <chiptus@users.noreply.github.com> Co-authored-by: andres-portainer <91705312+andres-portainer@users.noreply.github.com> Co-authored-by: Josiah Clumont <josiah.clumont@portainer.io> Co-authored-by: Dakota Walsh <101994734+dakota-portainer@users.noreply.github.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { render } from '@testing-library/react';
|
|
|
|
import { createMockEnvironment } from '@/react-tools/test-mocks';
|
|
|
|
import { withTestQueryProvider } from '../test-utils/withTestQuery';
|
|
|
|
import { EdgeIndicator } from './EdgeIndicator';
|
|
|
|
test('when edge id is not set, should show unassociated label', async () => {
|
|
const { queryByLabelText } = await renderComponent();
|
|
|
|
const unassociatedLabel = queryByLabelText('unassociated');
|
|
|
|
expect(unassociatedLabel).toBeVisible();
|
|
});
|
|
|
|
test('given edge id and last checkin is set, should show heartbeat', async () => {
|
|
const { queryByLabelText } = await renderComponent('id', 1);
|
|
|
|
expect(queryByLabelText('edge-last-checkin')).toBeVisible();
|
|
});
|
|
|
|
async function renderComponent(
|
|
edgeId = '',
|
|
lastCheckInDate = 0,
|
|
checkInInterval = 0
|
|
) {
|
|
const environment = createMockEnvironment();
|
|
|
|
environment.EdgeID = edgeId;
|
|
environment.LastCheckInDate = lastCheckInDate;
|
|
environment.EdgeCheckinInterval = checkInInterval;
|
|
|
|
const Wrapped = withTestQueryProvider(EdgeIndicator);
|
|
|
|
const queries = render(
|
|
<Wrapped environment={environment} showLastCheckInDate />
|
|
);
|
|
|
|
await expect(queries.findByRole('status')).resolves.toBeVisible();
|
|
|
|
return queries;
|
|
}
|