mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 01:36:49 +00:00
Add some type checking to demo (#24567)
This commit is contained in:
parent
a4cdb294b1
commit
58dd778b3d
@ -1,9 +1,10 @@
|
|||||||
|
import type { validateConfig } from "../../../src/data/config";
|
||||||
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||||
|
|
||||||
export const mockConfig = (hass: MockHomeAssistant) => {
|
export const mockConfig = (hass: MockHomeAssistant) => {
|
||||||
hass.mockWS("validate_config", () => ({
|
hass.mockWS<typeof validateConfig>("validate_config", () => ({
|
||||||
actions: { valid: true },
|
actions: { valid: true, error: null },
|
||||||
conditions: { valid: true },
|
conditions: { valid: true, error: null },
|
||||||
triggers: { valid: true },
|
triggers: { valid: true, error: null },
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
@ -1,20 +1,26 @@
|
|||||||
|
import type { getConfigEntries } from "../../../src/data/config_entries";
|
||||||
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||||
|
|
||||||
export const mockConfigEntries = (hass: MockHomeAssistant) => {
|
export const mockConfigEntries = (hass: MockHomeAssistant) => {
|
||||||
hass.mockWS("config_entries/get", () => ({
|
hass.mockWS<typeof getConfigEntries>("config_entries/get", () => [
|
||||||
entry_id: "co2signal",
|
{
|
||||||
domain: "co2signal",
|
entry_id: "mock-entry-co2signal",
|
||||||
title: "Electricity Maps",
|
domain: "co2signal",
|
||||||
source: "user",
|
title: "Electricity Maps",
|
||||||
state: "loaded",
|
source: "user",
|
||||||
supports_options: false,
|
state: "loaded",
|
||||||
supports_remove_device: false,
|
supports_options: false,
|
||||||
supports_unload: true,
|
supports_remove_device: false,
|
||||||
supports_reconfigure: true,
|
supports_unload: true,
|
||||||
supported_subentry_types: {},
|
supports_reconfigure: true,
|
||||||
pref_disable_new_entities: false,
|
supported_subentry_types: {},
|
||||||
pref_disable_polling: false,
|
pref_disable_new_entities: false,
|
||||||
disabled_by: null,
|
pref_disable_polling: false,
|
||||||
reason: null,
|
disabled_by: null,
|
||||||
}));
|
reason: null,
|
||||||
|
num_subentries: 0,
|
||||||
|
error_reason_translation_key: null,
|
||||||
|
error_reason_translation_placeholders: null,
|
||||||
|
},
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
|
@ -40,13 +40,13 @@ export interface MockHomeAssistant extends HomeAssistant {
|
|||||||
addEntities(entites: Entity | Entity[], replace?: boolean);
|
addEntities(entites: Entity | Entity[], replace?: boolean);
|
||||||
updateTranslations(fragment: null | string, language?: string);
|
updateTranslations(fragment: null | string, language?: string);
|
||||||
addTranslations(translations: Record<string, string>, language?: string);
|
addTranslations(translations: Record<string, string>, language?: string);
|
||||||
mockWS(
|
mockWS<T extends (...args) => any = any>(
|
||||||
type: string,
|
type: string,
|
||||||
callback: (
|
callback: (
|
||||||
msg: any,
|
msg: any,
|
||||||
hass: MockHomeAssistant,
|
hass: MockHomeAssistant,
|
||||||
onChange?: (response: any) => void
|
onChange?: (response: any) => void
|
||||||
) => any
|
) => Awaited<ReturnType<T>>
|
||||||
);
|
);
|
||||||
mockAPI(path: string | RegExp, callback: MockRestCallback);
|
mockAPI(path: string | RegExp, callback: MockRestCallback);
|
||||||
mockEvent(event);
|
mockEvent(event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user