1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-19 18:28:42 +00:00

Get state translations from backend (#5581)

* Get state translations from backend

* Fix tests
This commit is contained in:
Paulus Schoutsen
2020-04-21 08:15:13 -07:00
committed by GitHub
parent b4b90ca59d
commit d27a17cf8e
6 changed files with 52 additions and 104 deletions

View File

@@ -14,7 +14,7 @@ describe("computeStateDisplay", () => {
};
assert.strictEqual(
computeStateDisplay(localize, stateObj, "en"),
"state.binary_sensor.default.off"
"component.binary_sensor.state._.off"
);
});
@@ -28,7 +28,7 @@ describe("computeStateDisplay", () => {
};
assert.strictEqual(
computeStateDisplay(localize, stateObj, "en"),
"state.binary_sensor.moisture.off"
"component.binary_sensor.state.moisture.off"
);
});
@@ -48,7 +48,7 @@ describe("computeStateDisplay", () => {
};
assert.strictEqual(
computeStateDisplay(altLocalize, stateObj, "en"),
"state.binary_sensor.default.off"
"component.binary_sensor.state.invalid_device_class.off"
);
});
@@ -105,7 +105,7 @@ describe("computeStateDisplay", () => {
it("Localizes sensor value with component translation", () => {
const altLocalize = (message, ...args) => {
if (message !== "component.sensor.state.custom_state") {
if (message !== "component.sensor.state._.custom_state") {
return "";
}
return localize(message, ...args);
@@ -117,7 +117,7 @@ describe("computeStateDisplay", () => {
};
assert.strictEqual(
computeStateDisplay(altLocalize, stateObj, "en"),
"component.sensor.state.custom_state"
"component.sensor.state._.custom_state"
);
});
@@ -184,46 +184,6 @@ describe("computeStateDisplay", () => {
);
});
it("Localizes zwave ready", () => {
const stateObj: any = {
entity_id: "zwave.test",
state: "ready",
attributes: {
query_stage: "Complete",
},
};
assert.strictEqual(
computeStateDisplay(localize, stateObj, "en"),
"state.zwave.default.ready"
);
});
it("Localizes zwave initializing", () => {
const stateObj: any = {
entity_id: "zwave.test",
state: "initializing",
attributes: {
query_stage: "Probe",
},
};
assert.strictEqual(
computeStateDisplay(localize, stateObj, "en"),
"state.zwave.query_stage.initializing: query_stage,Probe"
);
});
it("Localizes cover open", () => {
const stateObj: any = {
entity_id: "cover.test",
state: "open",
attributes: {},
};
assert.strictEqual(
computeStateDisplay(localize, stateObj, "en"),
"state.cover.open"
);
});
it("Localizes unavailable", () => {
const altLocalize = (message, ...args) => {
if (message === "state.sensor.unavailable") {