Files
advanced-camera-card/tests/config/profiles/index.test.ts
T

59 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { ProfileType } from '../../../src/config/types';
import { setProfiles } from '../../../src/config/profiles';
import { createConfig } from '../../test-utils';
describe('setProfiles', () => {
it('should handle failed parse', () => {
expect(setProfiles({ cameras: 'not_an_array' }, {})).toEqual({});
});
it('should handle no profiles', () => {
const input = createConfig();
const output = createConfig();
expect(setProfiles(input, output)).toEqual(input);
});
it('should handle invalid profiles', () => {
const input = createConfig();
const output = createConfig();
expect(setProfiles(input, output, ['bogus' as ProfileType])).toEqual(input);
});
it('should handle profiles', () => {
const input = {
type: 'frigate-hass-card',
cameras: [{}],
live: {
controls: {
timeline: {
// This will not be overridden.
style: 'stack',
},
},
},
};
expect(setProfiles(input, {}, ['scrubbing'])).toEqual({
live: {
controls: {
timeline: {
mode: 'below',
pan_mode: 'seek',
},
},
},
media_viewer: {
controls: {
timeline: {
mode: 'below',
style: 'ribbon',
pan_mode: 'seek',
},
},
},
});
});
});