fix: Match state trigger/condition semantics to HA (#2565)

* Closes #2530
This commit is contained in:
Dermot Duffy
2026-07-04 10:23:51 -07:00
committed by GitHub
parent 3494706225
commit 9f956fe89f
15 changed files with 825 additions and 69 deletions
+17
View File
@@ -5,6 +5,7 @@ import {
allPromises,
arefloatsApproximatelyEqual,
arrayify,
arrayifyWithFalsy,
arrayMove,
aspectRatioToStyle,
contentsChanged,
@@ -69,6 +70,22 @@ describe('arrayify', () => {
});
});
describe('arrayifyWithFalsy', () => {
it('should wrap a non-array in an array', () => {
expect(arrayifyWithFalsy(1)).toEqual([1]);
});
it('should return an existing array unchanged', () => {
const data = [1, 2, 3];
expect(arrayifyWithFalsy(data)).toBe(data);
});
it('should preserve falsy values instead of dropping them', () => {
expect(arrayifyWithFalsy(0)).toEqual([0]);
expect(arrayifyWithFalsy(false)).toEqual([false]);
expect(arrayifyWithFalsy('')).toEqual(['']);
expect(arrayifyWithFalsy(null)).toEqual([null]);
});
});
describe('setify', () => {
it('should convert non set to set', () => {
expect(setify(1)).toEqual(new Set([1]));