Add test for Record to catch this

This commit is contained in:
Nick Mowen 2022-10-11 14:37:48 -06:00
parent 4a8b14ba40
commit 50b51ea801

View File

@ -0,0 +1,27 @@
import { h } from 'preact';
import * as CameraImage from '../../components/CameraImage';
import * as Mqtt from '../../api/mqtt';
import Cameras from '../Cameras';
import { fireEvent, render, screen, waitForElementToBeRemoved } from 'testing-library';
describe('Recording Route', () => {
beforeEach(() => {
jest.spyOn(CameraImage, 'default').mockImplementation(() => <div data-testid="camera-image" />);
jest.spyOn(Mqtt, 'useMqtt').mockImplementation(() => ({ value: { payload: 'OFF' }, send: jest.fn() }));
});
test('shows an ActivityIndicator if not yet loaded', async () => {
render(<Cameras />);
expect(screen.queryByLabelText('Loading…')).toBeInTheDocument();
});
test('shows no recordings warning', async () => {
render(<Cameras />);
await waitForElementToBeRemoved(() => screen.queryByLabelText('Loading…'));
expect(screen.queryAllByText('No Recordings Found')).toBeInTheDocument();
});
});