feat: Make cameras optional (#2343)
This commit is contained in:
@@ -120,6 +120,14 @@ describe('getPTZTarget', () => {
|
||||
type: 'digital',
|
||||
});
|
||||
});
|
||||
|
||||
it('without cameraID', () => {
|
||||
const view = createView({
|
||||
view: 'live',
|
||||
camera: null,
|
||||
});
|
||||
expect(getPTZTarget(view, { cameraManager: createCameraManager() })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('in non-media views', () => {
|
||||
|
||||
@@ -123,4 +123,16 @@ describe('generateScreenshotTitle', () => {
|
||||
|
||||
expect(generateScreenshotFilename(view)).toBe('media_camera-1.jpg');
|
||||
});
|
||||
|
||||
it('should get title for live view without camera', () => {
|
||||
expect(generateScreenshotFilename(createView({ view: 'live', camera: null }))).toBe(
|
||||
'live_2023-06-13-21-54-01.jpg',
|
||||
);
|
||||
});
|
||||
|
||||
it('should get title for viewer view without camera', () => {
|
||||
expect(generateScreenshotFilename(createView({ view: 'media', camera: null }))).toBe(
|
||||
'media.jpg',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
getStreamCameraID,
|
||||
hasSubstream,
|
||||
removeSubstream,
|
||||
setSubstream,
|
||||
} from '../../src/utils/substream';
|
||||
import { View } from '../../src/view/view';
|
||||
import { createView } from '../test-utils';
|
||||
@@ -62,6 +63,25 @@ describe('hasSubstream/getStreamCameraID', () => {
|
||||
expect(getStreamCameraID(view, 'camera3')).toBe('camera3');
|
||||
});
|
||||
});
|
||||
|
||||
it('should correctly handle null cameras', () => {
|
||||
expect(getStreamCameraID(createView({ camera: null }))).toBeNull();
|
||||
expect(hasSubstream(createView({ camera: null }))).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('setSubstream', () => {
|
||||
it('should set substream', () => {
|
||||
const view = createView({ camera: 'camera1' });
|
||||
setSubstream(view, 'substream1');
|
||||
expect(view.context?.live?.overrides?.get('camera1')).toBe('substream1');
|
||||
});
|
||||
|
||||
it('should return null without a camera', () => {
|
||||
const view = createView({ camera: null });
|
||||
setSubstream(view, 'foo');
|
||||
expect(view.context).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeSubstream', () => {
|
||||
@@ -100,4 +120,12 @@ describe('removeSubstream', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should not remove substream without camera', () => {
|
||||
const view = createView({
|
||||
camera: null,
|
||||
});
|
||||
removeSubstream(view);
|
||||
expect(view.context).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user