Skip to content

Commit

Permalink
hass.call coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe-codez committed Sep 1, 2024
1 parent 472cf17 commit a22ae4a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ words:
- rtsp
- sonarjs
- mbit
- datetime
- kbit
- ssdp
- systype
Expand Down
65 changes: 65 additions & 0 deletions src/testing/workflow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,69 @@ describe("Workflows", () => {
);
});
});

describe("Call", () => {
const EXPECTED_KEYS = [
"persistent_notification",
"homeassistant",
"system_log",
"logger",
"recorder",
"person",
"frontend",
"cloud",
"ffmpeg",
"tts",
"scene",
"timer",
"input_number",
"conversation",
"input_select",
"zone",
"input_button",
"script",
"automation",
"logbook",
"input_boolean",
"button",
"switch",
"input_datetime",
"backup",
"shopping_list",
"counter",
"schedule",
"input_text",
"synapse",
"todo",
"notify",
"calendar",
];
it("does not allow set", async () => {
expect.assertions(1);
await runner(undefined, async ({ hass }) => {
try {
// @ts-expect-error testing
hass.call.button = {};
} catch (error) {
expect(error).toBeDefined();
}
});
});

it("provides keys via ownKeys", async () => {
expect.assertions(1);
await runner(undefined, async ({ hass }) => {
const keys = Object.keys(hass.call);
expect(keys).toEqual(EXPECTED_KEYS);
});
});

it("does has correctly", async () => {
expect.assertions(34);
await runner(undefined, async ({ hass }) => {
EXPECTED_KEYS.forEach(i => expect(i in hass.call).toBe(true));
expect("unknown_property" in hass.call).toBe(false);
});
});
});
});

0 comments on commit a22ae4a

Please sign in to comment.