diff --git a/web/src/components/AutoUpdatingCameraImage.jsx b/web/src/components/AutoUpdatingCameraImage.jsx index ec1f70929..b5cd2e8d0 100644 --- a/web/src/components/AutoUpdatingCameraImage.jsx +++ b/web/src/components/AutoUpdatingCameraImage.jsx @@ -4,7 +4,7 @@ import { useCallback, useState } from 'preact/hooks'; const MIN_LOAD_TIMEOUT_MS = 200; -export default function AutoUpdatingCameraImage({ camera, searchParams, showFps = true }) { +export default function AutoUpdatingCameraImage({ camera, searchParams = '', showFps = true }) { const [key, setKey] = useState(Date.now()); const [fps, setFps] = useState(0); diff --git a/web/src/components/__tests__/AutoUpdatingCameraImage.test.jsx b/web/src/components/__tests__/AutoUpdatingCameraImage.test.jsx new file mode 100644 index 000000000..b302ee122 --- /dev/null +++ b/web/src/components/__tests__/AutoUpdatingCameraImage.test.jsx @@ -0,0 +1,42 @@ +import { h } from 'preact'; +import AutoUpdatingCameraImage from '../AutoUpdatingCameraImage'; +import { screen, render } from '@testing-library/preact'; + +let mockOnload; +jest.mock('../CameraImage', () => { + function CameraImage({ onload, searchParams }) { + mockOnload = () => { + onload(); + }; + return