fix: Match state trigger/condition semantics to HA (#2565)
* Closes #2530
This commit is contained in:
@@ -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]));
|
||||
|
||||
Reference in New Issue
Block a user