1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-05-19 06:28:59 +01:00
Files
frontend/test/common/entity/context/get_device_context.test.ts
Wendelin b73707751a Z-Wave rebuild routes add detail progress (#51361)
* WIP new dialog use states

* WIP add zwave rebuild network routes details

* Enhance Z-Wave JS rebuild network routes dialog with loading indicators and improved progress handling

* Remove hass param from `domain-icon`

* Remove unneeded @states

* List more compact

* fix prettier

* fix tests

* Rename device context to getDeviceArea
2026-04-02 16:51:33 +03:00

44 lines
1013 B
TypeScript

import { describe, expect, it } from "vitest";
import { getDeviceArea } from "../../../../src/common/entity/context/get_device_context";
import { mockArea, mockDevice } from "./context-mock";
describe("getDeviceArea", () => {
it("returns undefined when the device has no area", () => {
const device = mockDevice({
id: "device_1",
});
const result = getDeviceArea(device, {});
expect(result).toBeUndefined();
});
it("returns the area when the device area exists", () => {
const device = mockDevice({
id: "device_2",
area_id: "area_1",
});
const area = mockArea({
area_id: "area_1",
});
const result = getDeviceArea(device, {
area_1: area,
});
expect(result).toEqual(area);
});
it("returns undefined when the device area is missing", () => {
const device = mockDevice({
id: "device_3",
area_id: "area_2",
});
const result = getDeviceArea(device, {});
expect(result).toBeUndefined();
});
});