Skip to content

Commit

Permalink
Mock subscribe template (home-assistant#7529)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Oct 29, 2020
1 parent 76a088e commit f1c16d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions demo/src/stubs/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ export const mockTemplate = (hass: MockHomeAssistant) => {
body: { message: "Template dev tool does not work in the demo." },
})
);
hass.mockWS("render_template", (msg, onChange) => {
onChange!({
result: msg.template,
listeners: { all: false, domains: [], entities: [], time: false },
});
return () => {};
});
};
10 changes: 9 additions & 1 deletion gallery/src/demos/demo-hui-markdown-card.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { html } from "@polymer/polymer/lib/utils/html-tag";
/* eslint-plugin-disable lit */
import { PolymerElement } from "@polymer/polymer/polymer-element";
import { mockTemplate } from "../../../demo/src/stubs/template";
import { provideHass } from "../../../src/fake_data/provide_hass";
import "../components/demo-cards";

const CONFIGS = [
Expand Down Expand Up @@ -254,7 +256,7 @@ const CONFIGS = [

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

static get properties() {
Expand All @@ -265,6 +267,12 @@ class DemoMarkdown extends PolymerElement {
},
};
}

public ready() {
super.ready();
const hass = provideHass(this.$.demos);
mockTemplate(hass);
}
}

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

0 comments on commit f1c16d6

Please sign in to comment.