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

32 lines
1.3 KiB
TypeScript

import { expect, it } from 'vitest';
import { copyConfig } from '../../../src/config/management';
import { DOORBELL_PROFILE } from '../../../src/config/profiles/doorbell';
import { setProfiles } from '../../../src/config/profiles/set-profiles';
import { advancedCameraCardConfigSchema } from '../../../src/config/schema/types';
import { createRawConfig } from '../test-utils';
it('should contain expected defaults', () => {
expect(DOORBELL_PROFILE).toEqual({
'cameras_global.triggers.doorbell': true,
'view.triggers.actions.interaction_mode': 'all',
'view.triggers.actions.trigger': 'call',
'view.triggers.actions.untrigger': 'call',
'view.triggers.show_trigger_status': true,
});
});
it('should be parseable after application', () => {
const rawInputConfig = createRawConfig();
// `setProfiles` writes into the config it is given, and Zod hands out a
// single shared instance of each default object, so the parse result must be
// cloned before it is mutated.
const parsedConfig = copyConfig(advancedCameraCardConfigSchema.parse(rawInputConfig));
setProfiles(rawInputConfig, parsedConfig, ['doorbell']);
// Reparse the config to ensure the profile did not introduce errors.
const parseResult = advancedCameraCardConfigSchema.safeParse(parsedConfig);
expect(parseResult.success, parseResult.error?.toString()).toBeTruthy();
});