Files
advanced-camera-card/tests/components-lib/icon-controller.test.ts
T
Dermot Duffy fc32727860 feat: Add support for Frigate reviews / detections [initial PR] (#2315)
- Add support for Frigate reviews / detections.
 - Add support for GenAI metadata.
- Significant internal refactor to more flexible "UnifiedQuery" to allow
mixing cameras with simple metadata and review metadata (e.g. a timeline
view of a Frigate camera with reviews, and a Reolink camera with simple
metadata).
 - Add support for folder media as camera media.

There are a few more PRs to commit prior to this going live, but
commiting this for now due to the scale of the change.

BREAKING CHANGE: `media_type` and `events_type` are retired under
`live`, `viewer` and `timeline` configuration sections, instead media
type is associated (once) with the camera under `media`.
2026-01-19 13:32:50 -08:00

84 lines
2.6 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { IconController } from '../../src/components-lib/icon-controller';
import { createHASS, createStateEntity } from '../test-utils';
describe('IconController', () => {
describe('should get custom icon', () => {
it('should return frigate SVG for frigate icon', () => {
expect(new IconController().getCustomIcon({ icon: 'frigate' })).toMatch(
/frigate.svg$/,
);
});
it('should return motioneye SVG for motioneye icon', () => {
expect(new IconController().getCustomIcon({ icon: 'motioneye' })).toMatch(
/motioneye.svg$/,
);
});
it('should return reolink SVG for reolink icon', () => {
expect(new IconController().getCustomIcon({ icon: 'reolink' })).toMatch(
/reolink.svg$/,
);
});
it('should return tplink SVG for tplink icon', () => {
expect(new IconController().getCustomIcon({ icon: 'tplink' })).toMatch(
/tplink.svg$/,
);
});
it('should return iris SVG for iris icon', () => {
expect(new IconController().getCustomIcon({ icon: 'iris' })).toMatch(/iris.svg$/);
});
it('should return null for mdi icon', () => {
expect(new IconController().getCustomIcon({ icon: 'mdi:car' })).toBeNull();
});
it('should return null for undefined icon', () => {
expect(new IconController().getCustomIcon()).toBeNull();
});
});
describe('should create state object for state badge', () => {
it('should return null for non-existent entity', () => {
expect(
new IconController().createStateObjectForStateBadge(
createHASS(),
'sensor.DOES_NOT_EXIST',
),
).toBeNull();
});
it('should return modified state object for existing entity', () => {
expect(
new IconController().createStateObjectForStateBadge(
createHASS({
'sensor.existing': createStateEntity({
entity_id: 'sensor.existing',
attributes: {
friendly_name: 'Existing',
icon: 'mdi:car',
entity_picture: 'http://example.com/image.jpg',
entity_picture_local: 'local.jpg',
},
}),
}),
'sensor.existing',
),
).toEqual(
expect.objectContaining({
entity_id: 'sensor.existing',
attributes: expect.objectContaining({
friendly_name: 'Existing',
icon: 'mdi:car',
entity_picture: undefined,
entity_picture_local: undefined,
}),
}),
);
});
});
});