mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-29 05:04:45 +01:00
Ts all the tests (#1998)
* Convert tests to TypeScript * Add types for tests * Rename files to TS * Fix up test imports * Fix TSC errors * Liiiint * Add types to util method signatures * Some more types
This commit is contained in:
58
test-mocha/common/entity/can_toggle_state_test.ts
Normal file
58
test-mocha/common/entity/can_toggle_state_test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { assert } from "chai";
|
||||
|
||||
import canToggleState from "../../../src/common/entity/can_toggle_state";
|
||||
|
||||
describe("canToggleState", () => {
|
||||
const hass: any = {
|
||||
services: {
|
||||
light: {
|
||||
turn_on: null, // Service keys only need to be present for test
|
||||
turn_off: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
it("Detects lights toggle", () => {
|
||||
const stateObj: any = {
|
||||
entity_id: "light.bla",
|
||||
state: "on",
|
||||
};
|
||||
assert.isTrue(canToggleState(hass, stateObj));
|
||||
});
|
||||
|
||||
it("Detects group with toggle", () => {
|
||||
const stateObj: any = {
|
||||
entity_id: "group.bla",
|
||||
state: "on",
|
||||
};
|
||||
assert.isTrue(canToggleState(hass, stateObj));
|
||||
});
|
||||
|
||||
it("Detects group without toggle", () => {
|
||||
const stateObj: any = {
|
||||
entity_id: "group.devices",
|
||||
state: "home",
|
||||
};
|
||||
assert.isFalse(canToggleState(hass, stateObj));
|
||||
});
|
||||
|
||||
it("Detects climate with toggle", () => {
|
||||
const stateObj: any = {
|
||||
entity_id: "climate.bla",
|
||||
attributes: {
|
||||
supported_features: 4096,
|
||||
},
|
||||
};
|
||||
assert.isTrue(canToggleState(hass, stateObj));
|
||||
});
|
||||
|
||||
it("Detects climate without toggle", () => {
|
||||
const stateObj: any = {
|
||||
entity_id: "climate.bla",
|
||||
attributes: {
|
||||
supported_features: 0,
|
||||
},
|
||||
};
|
||||
assert.isFalse(canToggleState(hass, stateObj));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user