Skip to content

Commit f1c16d6

Browse files
authored
Mock subscribe template (home-assistant#7529)
1 parent 76a088e commit f1c16d6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

demo/src/stubs/template.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ export const mockTemplate = (hass: MockHomeAssistant) => {
66
body: { message: "Template dev tool does not work in the demo." },
77
})
88
);
9+
hass.mockWS("render_template", (msg, onChange) => {
10+
onChange!({
11+
result: msg.template,
12+
listeners: { all: false, domains: [], entities: [], time: false },
13+
});
14+
return () => {};
15+
});
916
};

gallery/src/demos/demo-hui-markdown-card.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { html } from "@polymer/polymer/lib/utils/html-tag";
22
/* eslint-plugin-disable lit */
33
import { PolymerElement } from "@polymer/polymer/polymer-element";
4+
import { mockTemplate } from "../../../demo/src/stubs/template";
5+
import { provideHass } from "../../../src/fake_data/provide_hass";
46
import "../components/demo-cards";
57

68
const CONFIGS = [
@@ -254,7 +256,7 @@ const CONFIGS = [
254256

255257
class DemoMarkdown extends PolymerElement {
256258
static get template() {
257-
return html` <demo-cards configs="[[_configs]]"></demo-cards> `;
259+
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
258260
}
259261

260262
static get properties() {
@@ -265,6 +267,12 @@ class DemoMarkdown extends PolymerElement {
265267
},
266268
};
267269
}
270+
271+
public ready() {
272+
super.ready();
273+
const hass = provideHass(this.$.demos);
274+
mockTemplate(hass);
275+
}
268276
}
269277

270278
customElements.define("demo-hui-markdown-card", DemoMarkdown);

0 commit comments

Comments
 (0)