Add out-of-the-box Frigate PTZ support.

This commit is contained in:
Dermot Duffy
2023-10-29 14:10:41 -07:00
parent fa43d2e439
commit e12912fa85
74 changed files with 3981 additions and 1514 deletions
+36
View File
@@ -0,0 +1,36 @@
import { describe, expect, it } from 'vitest';
import { FrigateCardPTZConfig, frigateCardPTZSchema } from '../../src/config/types';
import { hasUsablePTZ } from '../../src/utils/ptz';
import { createCameraCapabilities } from '../test-utils';
const createPTZConfig = (
config?: Partial<FrigateCardPTZConfig>,
): FrigateCardPTZConfig => {
return frigateCardPTZSchema.parse(config ?? {});
};
describe('hasUsablePTZ', () => {
it('should return true with manual actions', () => {
expect(
hasUsablePTZ(
createCameraCapabilities(),
createPTZConfig({
actions_left: {},
}),
),
).toBeTruthy();
});
it('should return true with capabilities', () => {
expect(
hasUsablePTZ(
createCameraCapabilities({
ptz: {},
}),
createPTZConfig(),
),
).toBeTruthy();
});
it('should return false with manual actions or capabilities', () => {
expect(hasUsablePTZ(createCameraCapabilities(), createPTZConfig())).toBeFalsy();
});
});