feat: Implement basic general folder support (#2051)

- Related: #1748
This commit is contained in:
Dermot Duffy
2025-05-21 19:59:21 -07:00
committed by GitHub
parent 2eb0d9e35e
commit c6a4c8aea2
350 changed files with 12837 additions and 4509 deletions
+35
View File
@@ -0,0 +1,35 @@
import { describe, expect, it } from 'vitest';
import { getEntitiesFromHASS } from '../../src/ha/get-entities';
import { createHASS, createStateEntity } from '../test-utils';
describe('getEntitiesFromHASS', () => {
const hass = createHASS({
'camera.front_door': createStateEntity(),
'light.kitchen': createStateEntity(),
'light.living_room': createStateEntity(),
'sensor.temperature': createStateEntity(),
'switch.garage': createStateEntity(),
});
it('returns all entity ids when no domain is specified', () => {
expect(getEntitiesFromHASS(hass)).toEqual([
'camera.front_door',
'light.kitchen',
'light.living_room',
'sensor.temperature',
'switch.garage',
]);
});
it('returns only entities of the specified domain', () => {
expect(getEntitiesFromHASS(hass, 'light')).toEqual([
'light.kitchen',
'light.living_room',
]);
});
it('returns an empty array if no entities match the domain', () => {
const result = getEntitiesFromHASS(hass, 'binary_sensor');
expect(result).toEqual([]);
});
});