mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-02 00:27:49 +01:00
Fix negative monetary values displayed as positive (#30178)
This commit is contained in:
@@ -144,6 +144,7 @@ const computeStateToPartsFromEntityAttributes = (
|
||||
fraction: "value",
|
||||
literal: "literal",
|
||||
currency: "unit",
|
||||
minusSign: "value",
|
||||
};
|
||||
|
||||
const valueParts: ValuePart[] = [];
|
||||
|
||||
@@ -684,6 +684,26 @@ describe("computeStateDisplayFromEntityAttributes with numeric device classes",
|
||||
);
|
||||
expect(result).toBe("$12.00");
|
||||
});
|
||||
|
||||
it("Should format negative monetary device_class", () => {
|
||||
const result = computeStateDisplayFromEntityAttributes(
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
(() => {}) as any,
|
||||
{
|
||||
language: "en",
|
||||
} as FrontendLocaleData,
|
||||
[],
|
||||
{} as HassConfig,
|
||||
undefined,
|
||||
"number.test",
|
||||
{
|
||||
device_class: "monetary",
|
||||
unit_of_measurement: "USD",
|
||||
},
|
||||
"-12"
|
||||
);
|
||||
expect(result).toBe("-$12.00");
|
||||
});
|
||||
});
|
||||
|
||||
describe("computeStateDisplayFromEntityAttributes datetime device calss", () => {
|
||||
|
||||
Reference in New Issue
Block a user