mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
fix tests
This commit is contained in:
parent
175c85d69a
commit
d83ffd8984
@ -3,6 +3,7 @@ import * as AutoUpdatingCameraImage from '../../components/AutoUpdatingCameraIma
|
|||||||
import * as Api from '../../api';
|
import * as Api from '../../api';
|
||||||
import * as Context from '../../context';
|
import * as Context from '../../context';
|
||||||
import Camera from '../Camera';
|
import Camera from '../Camera';
|
||||||
|
import * as JSMpegPlayer from '../../components/JSMpegPlayer';
|
||||||
import { fireEvent, render, screen } from '@testing-library/preact';
|
import { fireEvent, render, screen } from '@testing-library/preact';
|
||||||
|
|
||||||
describe('Camera Route', () => {
|
describe('Camera Route', () => {
|
||||||
@ -18,6 +19,9 @@ describe('Camera Route', () => {
|
|||||||
jest.spyOn(AutoUpdatingCameraImage, 'default').mockImplementation(({ searchParams }) => {
|
jest.spyOn(AutoUpdatingCameraImage, 'default').mockImplementation(({ searchParams }) => {
|
||||||
return <div data-testid="mock-image">{searchParams.toString()}</div>;
|
return <div data-testid="mock-image">{searchParams.toString()}</div>;
|
||||||
});
|
});
|
||||||
|
jest.spyOn(JSMpegPlayer, 'default').mockImplementation(() => {
|
||||||
|
return <div data-testid="mock-jsmpeg" />;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reads camera feed options from persistence', async () => {
|
test('reads camera feed options from persistence', async () => {
|
||||||
@ -44,6 +48,7 @@ describe('Camera Route', () => {
|
|||||||
|
|
||||||
test('updates camera feed options to persistence', async () => {
|
test('updates camera feed options to persistence', async () => {
|
||||||
mockUsePersistence
|
mockUsePersistence
|
||||||
|
.mockReturnValueOnce([{}, mockSetOptions])
|
||||||
.mockReturnValueOnce([{}, mockSetOptions])
|
.mockReturnValueOnce([{}, mockSetOptions])
|
||||||
.mockReturnValueOnce([{ bbox: true }, mockSetOptions])
|
.mockReturnValueOnce([{ bbox: true }, mockSetOptions])
|
||||||
.mockReturnValueOnce([{ bbox: true, timestamp: true }, mockSetOptions]);
|
.mockReturnValueOnce([{ bbox: true, timestamp: true }, mockSetOptions]);
|
||||||
@ -56,6 +61,8 @@ describe('Camera Route', () => {
|
|||||||
fireEvent.change(screen.queryByTestId('timestamp-input'), { target: { checked: true } });
|
fireEvent.change(screen.queryByTestId('timestamp-input'), { target: { checked: true } });
|
||||||
fireEvent.click(screen.queryByText('Hide Options'));
|
fireEvent.click(screen.queryByText('Hide Options'));
|
||||||
|
|
||||||
|
expect(mockUsePersistence).toHaveBeenCalledTimes(4);
|
||||||
|
expect(mockSetOptions).toHaveBeenCalledTimes(2);
|
||||||
expect(mockSetOptions).toHaveBeenCalledWith({ bbox: true, timestamp: true });
|
expect(mockSetOptions).toHaveBeenCalledWith({ bbox: true, timestamp: true });
|
||||||
expect(screen.queryByTestId('mock-image')).toHaveTextContent('bbox=1×tamp=1');
|
expect(screen.queryByTestId('mock-image')).toHaveTextContent('bbox=1×tamp=1');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user