1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-24 20:55:49 +00:00

Measurement number format (#10459)

This commit is contained in:
Josh McCarty
2021-11-01 01:32:22 -07:00
committed by GitHub
parent 4624c3d75b
commit b188c4ec81
5 changed files with 39 additions and 7 deletions

View File

@@ -96,6 +96,20 @@ describe("computeStateDisplay", () => {
);
});
it("Localizes and formats numeric sensor value with state_class", () => {
const stateObj: any = {
entity_id: "sensor.test",
state: "1234.5",
attributes: {
state_class: "measurement",
},
};
assert.strictEqual(
computeStateDisplay(localize, stateObj, localeData),
"1,234.5 m"
);
});
it("Localizes unknown sensor value with units", () => {
const altLocalize = (message, ...args) => {
if (message === "state.sensor.unknown") {