mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-19 08:20:41 +01:00
Rspack (#22807)
* Add rspack * Remove TransformAsyncModulesPlugin from rspack * Migrate all webpack usage to rspack * Migrate tests to vitest * Fix test suites * Remove chai dependency * Fix compute_state_display tests * Fix resolveTimeZone * Reduces test pipeline * Revert test ci * optimize chunk filtering * Migrate landing-page to rspack * Update rspack dependencies * Add rsdoctor * Fix prod build bundle size * Use rsdoctor for demo stats * Remove unused webpack configs * Update build-scripts/rspack.cjs Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com> * Fix eslint * Update rspack * Remove unused code --------- Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
This commit is contained in:
66
test/common/entity/can_toggle_state.test.ts
Normal file
66
test/common/entity/can_toggle_state.test.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { assert, describe, it } from "vitest";
|
||||
|
||||
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,
|
||||
},
|
||||
},
|
||||
states: {
|
||||
"light.bla": { entity_id: "light.bla" },
|
||||
"light.test": { entity_id: "light.test" },
|
||||
},
|
||||
};
|
||||
|
||||
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",
|
||||
attributes: {
|
||||
entity_id: ["light.bla", "light.test"],
|
||||
},
|
||||
};
|
||||
|
||||
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