Add support for pre-defined zoom/pan settings.
This commit is contained in:
@@ -5,6 +5,7 @@ import { actionSchema } from '../../src/config/types';
|
||||
import {
|
||||
convertActionToFrigateCardCustomAction,
|
||||
createFrigateCardCameraAction,
|
||||
createFrigateCardChangeZoomAction,
|
||||
createFrigateCardDisplayModeAction,
|
||||
createFrigateCardMediaPlayerAction,
|
||||
createFrigateCardShowPTZAction,
|
||||
@@ -114,6 +115,38 @@ describe('createFrigateCardShowPTZAction', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('createFrigateCardChangeZoomAction', () => {
|
||||
it('should create change zoom default action', () => {
|
||||
expect(
|
||||
createFrigateCardChangeZoomAction('target_id', {
|
||||
cardID: 'card_id',
|
||||
}),
|
||||
).toEqual({
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'change_zoom',
|
||||
card_id: 'card_id',
|
||||
target_id: 'target_id',
|
||||
});
|
||||
});
|
||||
|
||||
it('should create change zoom specific action', () => {
|
||||
expect(
|
||||
createFrigateCardChangeZoomAction('target_id', {
|
||||
cardID: 'card_id',
|
||||
pan: { x: 1, y: 2 },
|
||||
zoom: 3,
|
||||
}),
|
||||
).toEqual({
|
||||
action: 'fire-dom-event',
|
||||
frigate_card_action: 'change_zoom',
|
||||
card_id: 'card_id',
|
||||
target_id: 'target_id',
|
||||
pan: { x: 1, y: 2 },
|
||||
zoom: 3,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getActionConfigGivenAction', () => {
|
||||
const action = actionSchema.parse({
|
||||
action: 'fire-dom-event',
|
||||
|
||||
@@ -2,6 +2,7 @@ import { afterAll, describe, expect, it, vi } from 'vitest';
|
||||
import { FrigateCardError } from '../../src/types';
|
||||
import {
|
||||
allPromises,
|
||||
arefloatsApproximatelyEqual,
|
||||
arrayify,
|
||||
arrayMove,
|
||||
aspectRatioToStyle,
|
||||
@@ -12,6 +13,7 @@ import {
|
||||
errorToConsole,
|
||||
formatDate,
|
||||
formatDateAndTime,
|
||||
generateFloatApproximatelyEqualsCustomizer,
|
||||
getChildrenFromElement,
|
||||
getDurationString,
|
||||
isHoverableDevice,
|
||||
@@ -406,3 +408,54 @@ describe('desparsifyArrays', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('arefloatsApproximatelyEqual', () => {
|
||||
describe('without precision', () => {
|
||||
it('equals', () => {
|
||||
expect(arefloatsApproximatelyEqual(1.1, 1.2)).toBeTruthy();
|
||||
});
|
||||
it('not equals', () => {
|
||||
expect(arefloatsApproximatelyEqual(0.5, 1.5)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
describe('with precision', () => {
|
||||
it('equals', () => {
|
||||
expect(arefloatsApproximatelyEqual(1.00001, 1.00002, 4)).toBeTruthy();
|
||||
});
|
||||
it('not equals', () => {
|
||||
expect(arefloatsApproximatelyEqual(0.5, 1.5, 4)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateFloatApproximatelyEqualsCustomizer', () => {
|
||||
describe('with incorrect types', () => {
|
||||
it('undefined a', () => {
|
||||
expect(
|
||||
generateFloatApproximatelyEqualsCustomizer(4)(undefined, 1.2),
|
||||
).toBeUndefined();
|
||||
});
|
||||
it('undefined b', () => {
|
||||
expect(
|
||||
generateFloatApproximatelyEqualsCustomizer(4)(1.2, undefined),
|
||||
).toBeUndefined();
|
||||
});
|
||||
it('strings', () => {
|
||||
expect(
|
||||
generateFloatApproximatelyEqualsCustomizer(4)('foo', 'bar'),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
describe('with correct types', () => {
|
||||
it('equals', () => {
|
||||
expect(
|
||||
generateFloatApproximatelyEqualsCustomizer(4)(1.00001, 1.00002),
|
||||
).toBeTruthy();
|
||||
});
|
||||
it('not equals', () => {
|
||||
expect(
|
||||
generateFloatApproximatelyEqualsCustomizer(5)(1.00001, 1.00002),
|
||||
).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user