Add out-of-the-box Frigate PTZ support.
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { mock } from 'vitest-mock-extended';
|
||||
import { CameraManager } from '../../src/camera-manager/manager.js';
|
||||
import { CameraConfigs } from '../../src/camera-manager/types.js';
|
||||
import { getAllDependentCameras, getCameraID } from '../../src/utils/camera.js';
|
||||
import { createCameraConfig, createCameraManager } from '../test-utils.js';
|
||||
|
||||
vi.mock('../../src/camera-manager/manager.js');
|
||||
import { getCameraID } from '../../src/utils/camera.js';
|
||||
import { createCameraConfig } from '../test-utils.js';
|
||||
|
||||
describe('getCameraID', () => {
|
||||
it('should get camera id with id', () => {
|
||||
@@ -25,7 +20,9 @@ describe('getCameraID', () => {
|
||||
expect(getCameraID(config)).toBe('foo');
|
||||
});
|
||||
it('should get camera id with go2rtc url and stream', () => {
|
||||
const config = createCameraConfig({ go2rtc: { url: 'https://foo', stream: 'office' } });
|
||||
const config = createCameraConfig({
|
||||
go2rtc: { url: 'https://foo', stream: 'office' },
|
||||
});
|
||||
expect(getCameraID(config)).toBe('https://foo#office');
|
||||
});
|
||||
it('should get camera id with frigate camera_name', () => {
|
||||
@@ -39,48 +36,3 @@ describe('getCameraID', () => {
|
||||
expect(getCameraID(config)).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAllDependentCameras', () => {
|
||||
it('should return null without cameraManager', () => {
|
||||
expect(getAllDependentCameras()).toBeNull();
|
||||
});
|
||||
it('should return null without cameraID', () => {
|
||||
expect(getAllDependentCameras(mock<CameraManager>())).toBeNull();
|
||||
});
|
||||
it('should return dependent cameras', () => {
|
||||
const cameraConfigs: CameraConfigs = new Map([
|
||||
[
|
||||
'one',
|
||||
createCameraConfig({
|
||||
dependencies: {
|
||||
cameras: ['two', 'three'],
|
||||
},
|
||||
}),
|
||||
],
|
||||
['two', createCameraConfig({})],
|
||||
]);
|
||||
|
||||
const cameraManager = createCameraManager({ configs: cameraConfigs });
|
||||
expect(getAllDependentCameras(cameraManager, 'one')).toEqual(
|
||||
new Set(['one', 'two']),
|
||||
);
|
||||
});
|
||||
it('should return all cameras', () => {
|
||||
const cameraConfigs: CameraConfigs = new Map([
|
||||
[
|
||||
'one',
|
||||
createCameraConfig({
|
||||
dependencies: {
|
||||
all_cameras: true,
|
||||
},
|
||||
}),
|
||||
],
|
||||
['two', createCameraConfig({})],
|
||||
]);
|
||||
|
||||
const cameraManager = createCameraManager({ configs: cameraConfigs });
|
||||
expect(getAllDependentCameras(cameraManager, 'one')).toEqual(
|
||||
new Set(['one', 'two']),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user