Improve engine identification and id generation.
This commit is contained in:
@@ -20,6 +20,14 @@ describe('getCameraID', () => {
|
||||
const config = createCameraConfig({ webrtc_card: { entity: 'foo' } });
|
||||
expect(getCameraID(config)).toBe('foo');
|
||||
});
|
||||
it('should get camera id with webrtc url', () => {
|
||||
const config = createCameraConfig({ webrtc_card: { url: 'foo' } });
|
||||
expect(getCameraID(config)).toBe('foo');
|
||||
});
|
||||
it('should get camera id with go2rtc url and stream', () => {
|
||||
const config = createCameraConfig({ go2rtc: { url: 'https://foo', stream: 'office' } });
|
||||
expect(getCameraID(config)).toBe('https://foo#office');
|
||||
});
|
||||
it('should get camera id with frigate camera_name', () => {
|
||||
const config = createCameraConfig({
|
||||
frigate: { client_id: 'bar', camera_name: 'foo' },
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { HomeAssistant } from 'custom-card-helpers';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { hasHAConnectionStateChanged } from '../../../src/utils/ha/index.js';
|
||||
import { createHASS } from '../../test-utils.js';
|
||||
import {
|
||||
getEntityIcon,
|
||||
hasHAConnectionStateChanged,
|
||||
} from '../../../src/utils/ha/index.js';
|
||||
import { createHASS, createStateEntity } from '../../test-utils.js';
|
||||
|
||||
const createConnected = (connected: boolean): HomeAssistant => {
|
||||
const hass = createHASS();
|
||||
@@ -43,3 +46,24 @@ describe('hasHAConnectionStateChanged', () => {
|
||||
expect(hasHAConnectionStateChanged(null, null)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getEntityIcon', () => {
|
||||
it('should get icon from attributes', () => {
|
||||
expect(
|
||||
getEntityIcon(
|
||||
createHASS({
|
||||
'camera.test': createStateEntity({
|
||||
attributes: {
|
||||
icon: 'mdi:cow',
|
||||
},
|
||||
}),
|
||||
}),
|
||||
'camera.test',
|
||||
),
|
||||
).toBe('mdi:cow');
|
||||
});
|
||||
|
||||
it('should get icon from domain', () => {
|
||||
expect(getEntityIcon(createHASS(), 'camera.test')).toBe('mdi:video');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user