Skip to content

Commit

Permalink
Fixed null case
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwroc committed Feb 16, 2024
1 parent 8fe609b commit 6e067e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const getValueFromObject = (dataObject: any, path: string): string | numb
}
}

if (typeof dataObject == "object") {
if (dataObject !== null && typeof dataObject == "object") {
dataObject = JSON.stringify(dataObject);
}

Expand Down
18 changes: 10 additions & 8 deletions test/other/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ describe("Filter", () => {
expect(isValid).toBe(expectedIsVlid);
})
test.each([
[44, <FilterOperator>"<", "44,1", true],
[44, <FilterOperator>">", "44.1", false],
[true, <FilterOperator>"=", "false", false],
[true, <FilterOperator>"=", "true", false],
[true, <FilterOperator>"=", true, true],
[true, undefined, true, true],
[false, undefined, true, false],
[true, undefined, false, false],
// [44, <FilterOperator>"<", "44,1", true],
// [44, <FilterOperator>">", "44.1", false],
// [true, <FilterOperator>"=", "false", false],
// [true, <FilterOperator>"=", "true", false],
// [true, <FilterOperator>"=", true, true],
// [true, undefined, true, true],
// [false, undefined, true, false],
// [true, undefined, false, false],
// [true, undefined, null, false],
[null, undefined, null, true],
])("non mixed types of values", (attributeValue: FilterValueType, operator: FilterOperator | undefined, value: FilterValueType, expectedIsVlid: boolean) => {
const hassMock = new HomeAssistantMock();

Expand Down

0 comments on commit 6e067e2

Please sign in to comment.