@digital-alchemy/hass 24.8.1 → 24.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dynamic.d.ts +5 -4
- package/dist/extensions/area.extension.js +1 -1
- package/dist/extensions/call-proxy.extension.js +10 -0
- package/dist/extensions/call-proxy.extension.js.map +1 -1
- package/dist/extensions/config.extension.d.ts +2 -1
- package/dist/extensions/config.extension.js +7 -2
- package/dist/extensions/config.extension.js.map +1 -1
- package/dist/extensions/device.extension.js +1 -1
- package/dist/extensions/entity.extension.js +1 -1
- package/dist/extensions/floor.extension.js +1 -1
- package/dist/extensions/id-by.extension.js +14 -2
- package/dist/extensions/id-by.extension.js.map +1 -1
- package/dist/extensions/label.extension.js +1 -1
- package/dist/extensions/reference.extension.d.ts +1 -1
- package/dist/extensions/reference.extension.js +47 -1
- package/dist/extensions/reference.extension.js.map +1 -1
- package/dist/extensions/zone.extension.js +1 -1
- package/dist/hass.module.d.ts +1 -1
- package/dist/hass.module.js +2 -2
- package/dist/helpers/notify.helper.d.ts +76 -25
- package/dist/testing/area.spec.js +1 -1
- package/dist/testing/device.spec.js +1 -1
- package/dist/testing/entity.spec.js +2 -2
- package/dist/testing/floor.spec.js +1 -1
- package/dist/testing/id-by.spec.js +22 -3
- package/dist/testing/id-by.spec.js.map +1 -1
- package/dist/testing/label.spec.js +1 -1
- package/dist/testing/ref-by.spec.js +311 -226
- package/dist/testing/ref-by.spec.js.map +1 -1
- package/dist/testing/workflow.spec.js +63 -0
- package/dist/testing/workflow.spec.js.map +1 -1
- package/dist/testing/zone.spec.js +1 -1
- package/package.json +29 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-by.spec.js","sourceRoot":"","sources":["../../src/testing/id-by.spec.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"id-by.spec.js","sourceRoot":"","sources":["../../src/testing/id-by.spec.ts"],"names":[],"mappings":";;AAQA,sDAA0E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AAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAkB;oBACtC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE;wBACrB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;wBACvD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACjC,CAAC,CAAC,CAAC;gBACL,CAAC;aACF,CAAC,CAAC;YACH,MAAM,WAAW,CAAC,SAAS,CACzB,IAAA,4BAAW,EAAC,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CACnD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -164,7 +164,7 @@ describe("Label", () => {
|
|
|
164
164
|
},
|
|
165
165
|
}));
|
|
166
166
|
});
|
|
167
|
-
it("should
|
|
167
|
+
it("should debounce updates properly", async () => {
|
|
168
168
|
expect.assertions(1);
|
|
169
169
|
application = (0, utils_1.CreateTestingApplication)({
|
|
170
170
|
Test({ lifecycle, hass }) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
5
5
|
const mock_assistant_1 = require("../mock_assistant");
|
|
6
|
-
describe("
|
|
6
|
+
describe("References", () => {
|
|
7
7
|
let application;
|
|
8
8
|
afterEach(async () => {
|
|
9
9
|
if (application) {
|
|
@@ -12,241 +12,326 @@ describe("ID By", () => {
|
|
|
12
12
|
}
|
|
13
13
|
jest.restoreAllMocks();
|
|
14
14
|
});
|
|
15
|
-
describe("
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
lifecycle
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
expect.assertions(1);
|
|
31
|
-
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
32
|
-
Test({ lifecycle, hass }) {
|
|
33
|
-
lifecycle.onReady(() => {
|
|
34
|
-
const sensor = hass.refBy.id("sensor.magic");
|
|
35
|
-
expect(sensor.attributes).toEqual(expect.objectContaining({ friendly_name: "magic" }));
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
40
|
-
});
|
|
41
|
-
it("references do not return random attributes", async () => {
|
|
42
|
-
expect.assertions(1);
|
|
43
|
-
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
44
|
-
Test({ lifecycle, hass }) {
|
|
45
|
-
lifecycle.onReady(() => {
|
|
46
|
-
const sensor = hass.refBy.id("sensor.magic");
|
|
47
|
-
// @ts-expect-error it's the test
|
|
48
|
-
expect(sensor.foo).toBeUndefined();
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
53
|
-
});
|
|
54
|
-
it("references provide last_* as dayjs", async () => {
|
|
55
|
-
expect.assertions(3);
|
|
56
|
-
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
57
|
-
Test({ lifecycle, hass }) {
|
|
58
|
-
lifecycle.onReady(() => {
|
|
59
|
-
const sensor = hass.refBy.id("sensor.magic");
|
|
60
|
-
expect(sensor.last_changed instanceof dayjs_1.default).toBe(true);
|
|
61
|
-
expect(sensor.last_reported instanceof dayjs_1.default).toBe(true);
|
|
62
|
-
expect(sensor.last_updated instanceof dayjs_1.default).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
67
|
-
});
|
|
68
|
-
it("passes through history calls", async () => {
|
|
69
|
-
expect.assertions(2);
|
|
70
|
-
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
71
|
-
Test({ lifecycle, hass }) {
|
|
72
|
-
lifecycle.onReady(async () => {
|
|
73
|
-
const result = [];
|
|
74
|
-
const spy = jest
|
|
75
|
-
.spyOn(hass.fetch, "fetchEntityHistory")
|
|
76
|
-
.mockImplementation(async () => result);
|
|
77
|
-
const from = new Date();
|
|
78
|
-
const to = new Date();
|
|
79
|
-
const entity_id = "sensor.magic";
|
|
80
|
-
const entity = hass.refBy.id(entity_id);
|
|
81
|
-
const out = await entity.history(from, to);
|
|
82
|
-
expect(spy).toHaveBeenCalledWith(entity_id, from, to);
|
|
83
|
-
expect(out).toBe(result);
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
describe("domain", () => {
|
|
91
|
-
it("load references by domain", async () => {
|
|
92
|
-
expect.assertions(1);
|
|
93
|
-
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
94
|
-
Test({ lifecycle, hass }) {
|
|
95
|
-
lifecycle.onReady(() => {
|
|
96
|
-
const sensor = hass.refBy.domain("sensor");
|
|
97
|
-
expect(sensor.length).toBe(7);
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe("unique_id", () => {
|
|
105
|
-
it("load references by unique_id", async () => {
|
|
106
|
-
expect.assertions(1);
|
|
107
|
-
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
108
|
-
Test({ lifecycle, hass }) {
|
|
109
|
-
lifecycle.onReady(() => {
|
|
110
|
-
const sensor = hass.refBy.unique_id("e1806fdc93296bbd5ab42967003cd38729ff9ba6cfeefc3e15a03ad01ac894fe");
|
|
111
|
-
expect(sensor.entity_id).toBe("sensor.magic");
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
describe("label", () => {
|
|
119
|
-
it("load references by label", async () => {
|
|
120
|
-
expect.assertions(1);
|
|
121
|
-
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
122
|
-
Test({ lifecycle, hass }) {
|
|
123
|
-
lifecycle.onReady(() => {
|
|
124
|
-
const list = hass.refBy.label("synapse");
|
|
125
|
-
expect(list.length).toBe(7);
|
|
126
|
-
});
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
15
|
+
describe("loading", function () {
|
|
16
|
+
describe("refBy.id", () => {
|
|
17
|
+
it("can grab references by id", async () => {
|
|
18
|
+
expect.assertions(2);
|
|
19
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
20
|
+
Test({ lifecycle, hass }) {
|
|
21
|
+
lifecycle.onReady(() => {
|
|
22
|
+
const sensor = hass.refBy.id("sensor.magic");
|
|
23
|
+
expect(sensor).toBeDefined();
|
|
24
|
+
expect(sensor.state).toBe("unavailable");
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
29
|
+
});
|
|
130
30
|
});
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
lifecycle
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
31
|
+
describe("domain", () => {
|
|
32
|
+
it("load references by domain", async () => {
|
|
33
|
+
expect.assertions(1);
|
|
34
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
35
|
+
Test({ lifecycle, hass }) {
|
|
36
|
+
lifecycle.onReady(() => {
|
|
37
|
+
const sensor = hass.refBy.domain("sensor");
|
|
38
|
+
expect(sensor.length).toBe(8);
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
43
|
+
});
|
|
142
44
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
});
|
|
157
|
-
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
45
|
+
describe("unique_id", () => {
|
|
46
|
+
it("load references by unique_id", async () => {
|
|
47
|
+
expect.assertions(1);
|
|
48
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
49
|
+
Test({ lifecycle, hass }) {
|
|
50
|
+
lifecycle.onReady(() => {
|
|
51
|
+
const sensor = hass.refBy.unique_id("e1806fdc93296bbd5ab42967003cd38729ff9ba6cfeefc3e15a03ad01ac894fe");
|
|
52
|
+
expect(sensor.entity_id).toBe("sensor.magic");
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
57
|
+
});
|
|
158
58
|
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
lifecycle
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
59
|
+
describe("label", () => {
|
|
60
|
+
it("load references by label", async () => {
|
|
61
|
+
expect.assertions(1);
|
|
62
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
63
|
+
Test({ lifecycle, hass }) {
|
|
64
|
+
lifecycle.onReady(() => {
|
|
65
|
+
const list = hass.refBy.label("synapse");
|
|
66
|
+
expect(list.length).toBe(7);
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
71
|
+
});
|
|
72
|
+
it("load references by label limiting by domain", async () => {
|
|
73
|
+
expect.assertions(1);
|
|
74
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
75
|
+
Test({ lifecycle, hass }) {
|
|
76
|
+
lifecycle.onReady(() => {
|
|
77
|
+
const list = hass.refBy.label("synapse", "light");
|
|
78
|
+
expect(list.length).toBe(0);
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
83
|
+
});
|
|
172
84
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
85
|
+
describe("area", () => {
|
|
86
|
+
it("load references by area", async () => {
|
|
87
|
+
expect.assertions(2);
|
|
88
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
89
|
+
Test({ lifecycle, hass }) {
|
|
90
|
+
lifecycle.onReady(() => {
|
|
91
|
+
const bedroom = hass.refBy.area("bedroom");
|
|
92
|
+
const kitchen = hass.refBy.area("kitchen");
|
|
93
|
+
expect(bedroom.length).toBe(2);
|
|
94
|
+
expect(kitchen.length).toBe(1);
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
99
|
+
});
|
|
100
|
+
it("load references by area limiting by domain", async () => {
|
|
101
|
+
expect.assertions(2);
|
|
102
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
103
|
+
Test({ lifecycle, hass }) {
|
|
104
|
+
lifecycle.onReady(() => {
|
|
105
|
+
const bedroom = hass.refBy.area("bedroom", "light");
|
|
106
|
+
const kitchen = hass.refBy.area("kitchen", "light");
|
|
107
|
+
expect(bedroom.length).toBe(1);
|
|
108
|
+
expect(kitchen.length).toBe(0);
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
113
|
+
});
|
|
186
114
|
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
lifecycle
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
115
|
+
describe("device", () => {
|
|
116
|
+
it("load references by device", async () => {
|
|
117
|
+
expect.assertions(1);
|
|
118
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
119
|
+
Test({ lifecycle, hass }) {
|
|
120
|
+
lifecycle.onReady(() => {
|
|
121
|
+
const synapse = hass.refBy.device("308e39cf50a9fc6c30b4110724ed1f2e");
|
|
122
|
+
expect(synapse.length).toBe(9);
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
127
|
+
});
|
|
128
|
+
it("load references by device limiting by domain", async () => {
|
|
129
|
+
expect.assertions(1);
|
|
130
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
131
|
+
Test({ lifecycle, hass }) {
|
|
132
|
+
lifecycle.onReady(() => {
|
|
133
|
+
const synapse = hass.refBy.device("308e39cf50a9fc6c30b4110724ed1f2e", "light");
|
|
134
|
+
expect(synapse.length).toBe(0);
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
139
|
+
});
|
|
198
140
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
141
|
+
describe("platform", () => {
|
|
142
|
+
it("load references by platform", async () => {
|
|
143
|
+
expect.assertions(1);
|
|
144
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
145
|
+
Test({ lifecycle, hass }) {
|
|
146
|
+
lifecycle.onReady(() => {
|
|
147
|
+
const synapse = hass.refBy.platform("synapse");
|
|
148
|
+
expect(synapse.length).toBe(7);
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
153
|
+
});
|
|
154
|
+
it("load references by platform limiting by domain", async () => {
|
|
155
|
+
expect.assertions(1);
|
|
156
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
157
|
+
Test({ lifecycle, hass }) {
|
|
158
|
+
lifecycle.onReady(() => {
|
|
159
|
+
const synapse = hass.refBy.platform("synapse", "light");
|
|
160
|
+
expect(synapse.length).toBe(0);
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
165
|
+
});
|
|
212
166
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
lifecycle
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
167
|
+
describe("floor", () => {
|
|
168
|
+
it("load references by floor", async () => {
|
|
169
|
+
expect.assertions(1);
|
|
170
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
171
|
+
Test({ lifecycle, hass }) {
|
|
172
|
+
lifecycle.onReady(() => {
|
|
173
|
+
const synapse = hass.refBy.floor("downstairs");
|
|
174
|
+
expect(synapse.length).toBe(3);
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
179
|
+
});
|
|
180
|
+
it("load references by floor limiting by domain", async () => {
|
|
181
|
+
expect.assertions(1);
|
|
182
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
183
|
+
Test({ lifecycle, hass }) {
|
|
184
|
+
lifecycle.onReady(() => {
|
|
185
|
+
const synapse = hass.refBy.floor("downstairs", "light");
|
|
186
|
+
expect(synapse.length).toBe(0);
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
191
|
+
});
|
|
224
192
|
});
|
|
225
193
|
});
|
|
226
|
-
describe("
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
lifecycle
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
194
|
+
describe("functionality", () => {
|
|
195
|
+
describe("operators", () => {
|
|
196
|
+
it("has", async () => {
|
|
197
|
+
expect.assertions(15);
|
|
198
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
199
|
+
Test({ lifecycle, hass }) {
|
|
200
|
+
lifecycle.onReady(() => {
|
|
201
|
+
const entity = hass.refBy.id("switch.bedroom_lamp");
|
|
202
|
+
// always there stuff
|
|
203
|
+
expect("does not exist" in entity).toBe(false);
|
|
204
|
+
[
|
|
205
|
+
"attributes",
|
|
206
|
+
"entity_id",
|
|
207
|
+
"history",
|
|
208
|
+
"last",
|
|
209
|
+
"nextState",
|
|
210
|
+
"once",
|
|
211
|
+
"onUpdate",
|
|
212
|
+
"previous",
|
|
213
|
+
"removeAllListeners",
|
|
214
|
+
"state",
|
|
215
|
+
"waitForState",
|
|
216
|
+
].forEach(property => expect(property in entity).toBe(true));
|
|
217
|
+
// service calls exist too
|
|
218
|
+
["toggle", "turn_off", "turn_on"].forEach(method => expect(method in entity).toBe(true));
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
223
|
+
});
|
|
224
|
+
it("ownKeys", async () => {
|
|
225
|
+
expect.assertions(1);
|
|
226
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
227
|
+
Test({ lifecycle, hass }) {
|
|
228
|
+
lifecycle.onReady(() => {
|
|
229
|
+
const entity = hass.refBy.id("switch.bedroom_lamp");
|
|
230
|
+
const keys = Object.keys(entity);
|
|
231
|
+
// note: each section sorted alphabetically
|
|
232
|
+
expect(keys).toEqual([
|
|
233
|
+
// hard coded
|
|
234
|
+
"entity_id",
|
|
235
|
+
"state",
|
|
236
|
+
"attributes",
|
|
237
|
+
"last_changed",
|
|
238
|
+
"last_reported",
|
|
239
|
+
"last_updated",
|
|
240
|
+
"context",
|
|
241
|
+
"history",
|
|
242
|
+
"last",
|
|
243
|
+
"nextState",
|
|
244
|
+
"once",
|
|
245
|
+
"onUpdate",
|
|
246
|
+
"previous",
|
|
247
|
+
"removeAllListeners",
|
|
248
|
+
"waitForState",
|
|
249
|
+
// services
|
|
250
|
+
"toggle",
|
|
251
|
+
"turn_off",
|
|
252
|
+
"turn_on",
|
|
253
|
+
]);
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
258
|
+
});
|
|
259
|
+
describe("set", () => {
|
|
260
|
+
it("state", () => {
|
|
261
|
+
// stub
|
|
262
|
+
});
|
|
263
|
+
it("attributes", () => {
|
|
264
|
+
// stub
|
|
265
|
+
});
|
|
266
|
+
it("everything else", () => {
|
|
267
|
+
// stub
|
|
268
|
+
});
|
|
269
|
+
});
|
|
238
270
|
});
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
lifecycle
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
271
|
+
describe("get", () => {
|
|
272
|
+
it("references have attributes", async () => {
|
|
273
|
+
expect.assertions(2);
|
|
274
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
275
|
+
Test({ lifecycle, hass }) {
|
|
276
|
+
lifecycle.onReady(() => {
|
|
277
|
+
const sensor = hass.refBy.id("sensor.magic");
|
|
278
|
+
expect("attributes" in sensor).toBe(true);
|
|
279
|
+
expect(sensor.attributes).toEqual(expect.objectContaining({ friendly_name: "magic" }));
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
284
|
+
});
|
|
285
|
+
// mental note: legacy test
|
|
286
|
+
// better covered by the ownKeys & has operator tests now
|
|
287
|
+
it("references do not return random attributes", async () => {
|
|
288
|
+
expect.assertions(1);
|
|
289
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
290
|
+
Test({ lifecycle, hass }) {
|
|
291
|
+
lifecycle.onReady(() => {
|
|
292
|
+
const sensor = hass.refBy.id("sensor.magic");
|
|
293
|
+
// @ts-expect-error it's the test
|
|
294
|
+
expect(sensor.foo).toBeUndefined();
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
299
|
+
});
|
|
300
|
+
it("references provide last_* as dayjs", async () => {
|
|
301
|
+
expect.assertions(3);
|
|
302
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
303
|
+
Test({ lifecycle, hass }) {
|
|
304
|
+
lifecycle.onReady(() => {
|
|
305
|
+
const sensor = hass.refBy.id("sensor.magic");
|
|
306
|
+
expect(sensor.last_changed instanceof dayjs_1.default).toBe(true);
|
|
307
|
+
expect(sensor.last_reported instanceof dayjs_1.default).toBe(true);
|
|
308
|
+
expect(sensor.last_updated instanceof dayjs_1.default).toBe(true);
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
313
|
+
});
|
|
314
|
+
it("passes through history calls", async () => {
|
|
315
|
+
expect.assertions(2);
|
|
316
|
+
application = (0, mock_assistant_1.CreateTestingApplication)({
|
|
317
|
+
Test({ lifecycle, hass }) {
|
|
318
|
+
lifecycle.onReady(async () => {
|
|
319
|
+
const result = [];
|
|
320
|
+
const spy = jest
|
|
321
|
+
.spyOn(hass.fetch, "fetchEntityHistory")
|
|
322
|
+
.mockImplementation(async () => result);
|
|
323
|
+
const from = new Date();
|
|
324
|
+
const to = new Date();
|
|
325
|
+
const entity_id = "sensor.magic";
|
|
326
|
+
const entity = hass.refBy.id(entity_id);
|
|
327
|
+
const out = await entity.history(from, to);
|
|
328
|
+
expect(spy).toHaveBeenCalledWith(entity_id, from, to);
|
|
329
|
+
expect(out).toBe(result);
|
|
330
|
+
});
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
await application.bootstrap((0, mock_assistant_1.SILENT_BOOT)({ hass: { MOCK_SOCKET: true } }, true));
|
|
334
|
+
});
|
|
250
335
|
});
|
|
251
336
|
});
|
|
252
337
|
});
|