node-red-contrib-power-saver 4.1.3 → 4.1.5
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/CHANGELOG.md +1 -1
- package/docs/.vuepress/client.js +7 -0
- package/docs/.vuepress/clientAppEnhance.js +1 -1
- package/docs/.vuepress/components/AdsenseAdd.vue +1 -1
- package/docs/.vuepress/config.js +31 -30
- package/docs/README.md +6 -0
- package/docs/changelog/README.md +8 -0
- package/docs/examples/example-grid-tariff-capacity-part.md +16 -5
- package/docs/privacy.md +17 -0
- package/examples/example-grid-tariff-capacity-flow.json +2 -2
- package/package.json +19 -18
- package/src/schedule-merger-functions.js +2 -1
- package/src/strategy-heat-capacitor-functions.js +38 -4
- package/src/strategy-heat-capacitor.html +2 -2
- package/src/strategy-heat-capacitor.js +94 -63
- package/src/strategy-lowest-price.js +4 -2
- package/test/commands-input-best-save.test.js +15 -15
- package/test/commands-input-lowest-price.test.js +15 -15
- package/test/commands-input-schedule-merger.test.js +11 -11
- package/test/data/heat-capacitor-prices-NaN-test.json +197 -0
- package/test/data/lowest-price-bug184-input.json +197 -0
- package/test/data/lowest-price-bug184.json +341 -0
- package/test/elvia.test.js +2 -2
- package/test/general-add-tariff-functions.test.js +6 -6
- package/test/general-add-tariff.test.js +7 -7
- package/test/mostSavedStrategy.test.js +17 -17
- package/test/receive-price-functions.test.js +9 -9
- package/test/receive-price.test.js +11 -11
- package/test/schedule-merger-functions.test.js +18 -28
- package/test/schedule-merger.test.js +17 -17
- package/test/send-config-input.test.js +13 -13
- package/test/strategy-best-save-overlap.test.js +2 -2
- package/test/strategy-best-save.test.js +28 -28
- package/test/strategy-fixed-schedule.test.js +5 -5
- package/test/strategy-heat-capacitor-node.test.js +115 -16
- package/test/strategy-heat-capacitor.test.js +8 -6
- package/test/strategy-lowest-price-3days.test.js +4 -4
- package/test/strategy-lowest-price-bug184.test.js +60 -0
- package/test/strategy-lowest-price-functions.test.js +13 -13
- package/test/strategy-lowest-price.test.js +34 -34
- package/test/utils.test.js +46 -45
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const cloneDeep = require("lodash.clonedeep");
|
|
2
2
|
const { DateTime } = require("luxon");
|
|
3
|
-
const expect = require("
|
|
3
|
+
const expect = require("chai").expect;
|
|
4
4
|
const helper = require("node-red-node-test-helper");
|
|
5
5
|
const lowestPrice = require("../src/strategy-lowest-price.js");
|
|
6
6
|
const prices = require("./data/converted-prices.json");
|
|
@@ -25,7 +25,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
25
25
|
const flow = [{ id: "n1", type: "ps-strategy-lowest-price", name: "test name" }];
|
|
26
26
|
helper.load(lowestPrice, flow, function () {
|
|
27
27
|
const n1 = helper.getNode("n1");
|
|
28
|
-
expect(n1).
|
|
28
|
+
expect(n1).to.have.deep.property("name", "test name");
|
|
29
29
|
done();
|
|
30
30
|
});
|
|
31
31
|
});
|
|
@@ -66,8 +66,8 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
66
66
|
const n1 = helper.getNode("n1");
|
|
67
67
|
const n2 = helper.getNode("n2");
|
|
68
68
|
n2.on("input", function (msg) {
|
|
69
|
-
expect(msg.payload).
|
|
70
|
-
expect(msg.payload).
|
|
69
|
+
expect(msg.payload).to.have.deep.property("schedule", resultContinuous.schedule);
|
|
70
|
+
expect(msg.payload).to.have.deep.property("config", resultContinuous.config);
|
|
71
71
|
n1.warn.should.not.be.called;
|
|
72
72
|
done();
|
|
73
73
|
});
|
|
@@ -83,7 +83,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
83
83
|
const n1 = helper.getNode("n1");
|
|
84
84
|
const n2 = helper.getNode("n2");
|
|
85
85
|
n2.on("input", function (msg) {
|
|
86
|
-
expect(msg.payload).
|
|
86
|
+
expect(msg.payload).to.have.deep.property("schedule", resultSplitted.schedule);
|
|
87
87
|
n1.warn.should.not.be.called;
|
|
88
88
|
done();
|
|
89
89
|
});
|
|
@@ -98,8 +98,8 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
98
98
|
const n1 = helper.getNode("n1");
|
|
99
99
|
const n2 = helper.getNode("n2");
|
|
100
100
|
n2.on("input", function (msg) {
|
|
101
|
-
expect(msg.payload).
|
|
102
|
-
expect(msg.payload).
|
|
101
|
+
expect(msg.payload).to.have.deep.property("schedule", resultContinuous.schedule);
|
|
102
|
+
expect(msg.payload).to.have.deep.property("config", resultContinuous.config);
|
|
103
103
|
n1.warn.should.not.be.called;
|
|
104
104
|
done();
|
|
105
105
|
});
|
|
@@ -115,7 +115,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
115
115
|
const n1 = helper.getNode("n1");
|
|
116
116
|
const n2 = helper.getNode("n2");
|
|
117
117
|
n2.on("input", function (msg) {
|
|
118
|
-
expect(msg.payload).
|
|
118
|
+
expect(msg.payload).to.have.deep.property("schedule", resultSplitted.schedule);
|
|
119
119
|
n1.warn.should.not.be.called;
|
|
120
120
|
done();
|
|
121
121
|
});
|
|
@@ -130,7 +130,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
130
130
|
const n1 = helper.getNode("n1");
|
|
131
131
|
const n2 = helper.getNode("n2");
|
|
132
132
|
n2.on("input", function (msg) {
|
|
133
|
-
expect(msg.payload).
|
|
133
|
+
expect(msg.payload).to.have.deep.property("schedule", resultContinuousMax.schedule);
|
|
134
134
|
n1.warn.should.not.be.called;
|
|
135
135
|
done();
|
|
136
136
|
});
|
|
@@ -145,7 +145,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
145
145
|
const n1 = helper.getNode("n1");
|
|
146
146
|
const n2 = helper.getNode("n2");
|
|
147
147
|
n2.on("input", function (msg) {
|
|
148
|
-
expect(msg.payload).
|
|
148
|
+
expect(msg.payload).to.have.deep.property("schedule", resultContinuousMax.schedule);
|
|
149
149
|
n1.warn.should.not.be.called;
|
|
150
150
|
done();
|
|
151
151
|
});
|
|
@@ -161,7 +161,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
161
161
|
const n1 = helper.getNode("n1");
|
|
162
162
|
const n2 = helper.getNode("n2");
|
|
163
163
|
n2.on("input", function (msg) {
|
|
164
|
-
expect(msg.payload).
|
|
164
|
+
expect(msg.payload).to.have.deep.property("schedule", resultSplittedMax.schedule);
|
|
165
165
|
n1.warn.should.not.be.called;
|
|
166
166
|
done();
|
|
167
167
|
});
|
|
@@ -179,7 +179,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
179
179
|
const n1 = helper.getNode("n1");
|
|
180
180
|
const n2 = helper.getNode("n2");
|
|
181
181
|
n2.on("input", function (msg) {
|
|
182
|
-
expect(msg.payload).
|
|
182
|
+
expect(msg.payload).to.have.deep.property("schedule", resultAllDay.schedule);
|
|
183
183
|
n1.warn.should.not.be.called;
|
|
184
184
|
done();
|
|
185
185
|
});
|
|
@@ -198,7 +198,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
198
198
|
const n2 = helper.getNode("n2");
|
|
199
199
|
n2.on("input", function (msg) {
|
|
200
200
|
const config = cloneDeep(resultAllDay10.config);
|
|
201
|
-
expect(msg.payload).
|
|
201
|
+
expect(msg.payload).to.have.deep.property("schedule", resultAllDay10.schedule);
|
|
202
202
|
n1.warn.should.not.be.called;
|
|
203
203
|
done();
|
|
204
204
|
});
|
|
@@ -219,7 +219,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
219
219
|
n2.on("input", function (msg) {
|
|
220
220
|
const config = cloneDeep(resultAllDay10.config);
|
|
221
221
|
config.outputOutsidePeriod = true;
|
|
222
|
-
expect(msg.payload).
|
|
222
|
+
expect(msg.payload).to.have.deep.property("schedule", resultAllDay10.schedule);
|
|
223
223
|
n1.warn.should.not.be.called;
|
|
224
224
|
done();
|
|
225
225
|
});
|
|
@@ -240,7 +240,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
240
240
|
n2.on("input", function (msg) {
|
|
241
241
|
const config = cloneDeep(resultAllDay10.config);
|
|
242
242
|
config.outputIfNoSchedule = true;
|
|
243
|
-
expect(msg.payload).
|
|
243
|
+
expect(msg.payload).to.have.deep.property("schedule", resultAllDay10.schedule);
|
|
244
244
|
n1.warn.should.not.be.called;
|
|
245
245
|
done();
|
|
246
246
|
});
|
|
@@ -268,7 +268,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
268
268
|
const res = msg.payload.schedule.map((s) => ({ time: s.time, value: s.value }));
|
|
269
269
|
const exp = schedule.map((s) => ({ time: s.time, value: s.value }));
|
|
270
270
|
exp.pop();
|
|
271
|
-
expect(res).
|
|
271
|
+
expect(res).to.eql(exp);
|
|
272
272
|
n1.warn.should.not.be.called;
|
|
273
273
|
done();
|
|
274
274
|
});
|
|
@@ -296,8 +296,8 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
296
296
|
const res = msg.payload.schedule.map((s) => ({ time: s.time, value: s.value }));
|
|
297
297
|
const exp = schedule.map((s) => ({ time: s.time, value: s.value }));
|
|
298
298
|
exp.splice(8, 1);
|
|
299
|
-
expect(res).
|
|
300
|
-
expect(msg.payload).
|
|
299
|
+
expect(res).to.eql(exp);
|
|
300
|
+
expect(msg.payload).to.have.deep.property("config", config);
|
|
301
301
|
n1.warn.should.not.be.called;
|
|
302
302
|
done();
|
|
303
303
|
});
|
|
@@ -315,7 +315,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
315
315
|
const n1 = helper.getNode("n1");
|
|
316
316
|
const n2 = helper.getNode("n2");
|
|
317
317
|
n2.on("input", function (msg) {
|
|
318
|
-
expect(msg.payload).
|
|
318
|
+
expect(msg.payload).to.have.deep.property("schedule", result);
|
|
319
319
|
n1.warn.should.not.be.called;
|
|
320
320
|
done();
|
|
321
321
|
});
|
|
@@ -337,7 +337,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
337
337
|
const n1 = helper.getNode("n1");
|
|
338
338
|
const n2 = helper.getNode("n2");
|
|
339
339
|
n2.on("input", function (msg) {
|
|
340
|
-
expect(msg.payload).
|
|
340
|
+
expect(msg.payload).to.have.deep.property("schedule", result);
|
|
341
341
|
n1.warn.should.not.be.called;
|
|
342
342
|
done();
|
|
343
343
|
});
|
|
@@ -359,7 +359,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
359
359
|
const n1 = helper.getNode("n1");
|
|
360
360
|
const n2 = helper.getNode("n2");
|
|
361
361
|
n2.on("input", function (msg) {
|
|
362
|
-
expect(msg.payload).
|
|
362
|
+
expect(msg.payload).to.have.deep.property("schedule", result);
|
|
363
363
|
n1.warn.should.not.be.called;
|
|
364
364
|
done();
|
|
365
365
|
});
|
|
@@ -381,7 +381,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
381
381
|
const n1 = helper.getNode("n1");
|
|
382
382
|
const n2 = helper.getNode("n2");
|
|
383
383
|
n2.on("input", function (msg) {
|
|
384
|
-
expect(msg.payload).
|
|
384
|
+
expect(msg.payload).to.have.deep.property("schedule", result);
|
|
385
385
|
n1.warn.should.not.be.called;
|
|
386
386
|
done();
|
|
387
387
|
});
|
|
@@ -406,17 +406,17 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
406
406
|
const n3 = helper.getNode("n3");
|
|
407
407
|
const n4 = helper.getNode("n4");
|
|
408
408
|
n2.on("input", function (msg) {
|
|
409
|
-
expect(msg.payload).
|
|
409
|
+
expect(msg.payload).to.have.deep.property("schedule", result);
|
|
410
410
|
n1.warn.should.not.be.called;
|
|
411
411
|
done();
|
|
412
412
|
});
|
|
413
413
|
n3.on("input", function (msg) {
|
|
414
414
|
console.log("n3 inout: " + msg);
|
|
415
|
-
expect(msg.payload).
|
|
415
|
+
expect(msg.payload).to.equal(true);
|
|
416
416
|
});
|
|
417
417
|
n4.on("input", function (msg) {
|
|
418
418
|
console.log("n4 inout: " + msg);
|
|
419
|
-
expect(msg.payload).
|
|
419
|
+
expect(msg.payload).to.equal(false);
|
|
420
420
|
});
|
|
421
421
|
const time = DateTime.fromISO(prices.priceData[10].start);
|
|
422
422
|
n1.receive({ payload: makePayload(oneDayPrices, time) });
|
|
@@ -454,11 +454,11 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
454
454
|
let countOn = 0;
|
|
455
455
|
let countOff = 0;
|
|
456
456
|
n2.on("input", function (msg) {
|
|
457
|
-
expect(msg.payload).
|
|
457
|
+
expect(msg.payload).to.have.deep.property("schedule", result);
|
|
458
458
|
n1.warn.should.not.be.called;
|
|
459
459
|
setTimeout(() => {
|
|
460
|
-
expect(countOn).
|
|
461
|
-
expect(countOff).
|
|
460
|
+
expect(countOn).to.equal(1);
|
|
461
|
+
expect(countOff).to.equal(0);
|
|
462
462
|
done();
|
|
463
463
|
}, 100);
|
|
464
464
|
});
|
|
@@ -508,11 +508,11 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
508
508
|
let countOn = 0;
|
|
509
509
|
let countOff = 0;
|
|
510
510
|
n2.on("input", function (msg) {
|
|
511
|
-
expect(msg.payload).
|
|
511
|
+
expect(msg.payload).to.have.deep.property("schedule", result);
|
|
512
512
|
n1.warn.should.not.be.called;
|
|
513
513
|
setTimeout(() => {
|
|
514
|
-
expect(countOn).
|
|
515
|
-
expect(countOff).
|
|
514
|
+
expect(countOn).to.equal(0);
|
|
515
|
+
expect(countOff).to.equal(1);
|
|
516
516
|
done();
|
|
517
517
|
}, 100);
|
|
518
518
|
});
|
|
@@ -557,7 +557,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
557
557
|
const n1 = helper.getNode("n1");
|
|
558
558
|
const n2 = helper.getNode("n2");
|
|
559
559
|
n2.on("input", function (msg) {
|
|
560
|
-
expect(msg).
|
|
560
|
+
expect(msg).to.have.deep.property("payload", result);
|
|
561
561
|
n1.warn.should.not.be.called;
|
|
562
562
|
done();
|
|
563
563
|
});
|
|
@@ -594,7 +594,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
594
594
|
const n1 = helper.getNode("n1");
|
|
595
595
|
const n2 = helper.getNode("n2");
|
|
596
596
|
n2.on("input", function (msg) {
|
|
597
|
-
expect(msg).
|
|
597
|
+
expect(msg).to.have.deep.property("payload", result);
|
|
598
598
|
n1.warn.should.not.be.called;
|
|
599
599
|
done();
|
|
600
600
|
});
|
|
@@ -631,7 +631,7 @@ describe("ps-strategy-lowest-price node", function () {
|
|
|
631
631
|
const n1 = helper.getNode("n1");
|
|
632
632
|
const n2 = helper.getNode("n2");
|
|
633
633
|
n2.on("input", function (msg) {
|
|
634
|
-
expect(msg).
|
|
634
|
+
expect(msg).to.have.deep.property("payload", result.payload);
|
|
635
635
|
n1.warn.should.not.be.called;
|
|
636
636
|
done();
|
|
637
637
|
});
|
package/test/utils.test.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const cloneDeep = require("lodash.clonedeep");
|
|
2
2
|
const { DateTime } = require("luxon");
|
|
3
|
-
const expect = require("
|
|
3
|
+
const expect = require("chai").expect;
|
|
4
|
+
|
|
4
5
|
const {
|
|
5
6
|
booleanConfig,
|
|
6
7
|
sortedIndex,
|
|
@@ -18,49 +19,49 @@ const testResult = require("./data/best-save-result.json");
|
|
|
18
19
|
|
|
19
20
|
describe("utils", () => {
|
|
20
21
|
it("can test boolean config", () => {
|
|
21
|
-
expect(booleanConfig(true)).
|
|
22
|
-
expect(booleanConfig(false)).
|
|
23
|
-
expect(booleanConfig("true")).
|
|
24
|
-
expect(booleanConfig("false")).
|
|
25
|
-
expect(booleanConfig(undefined)).
|
|
22
|
+
expect(booleanConfig(true)).to.equal(true);
|
|
23
|
+
expect(booleanConfig(false)).to.equal(false);
|
|
24
|
+
expect(booleanConfig("true")).to.equal(true);
|
|
25
|
+
expect(booleanConfig("false")).to.equal(false);
|
|
26
|
+
expect(booleanConfig(undefined)).to.equal(false);
|
|
26
27
|
});
|
|
27
28
|
it("can sortedIndex", () => {
|
|
28
|
-
expect(sortedIndex([3, 1, 2, 4])).
|
|
29
|
+
expect(sortedIndex([3, 1, 2, 4])).to.eql([3, 0, 2, 1]);
|
|
29
30
|
});
|
|
30
31
|
it("returns the first on", () => {
|
|
31
|
-
expect(firstOn([1, 2, 3], [false, false, false], 0)).
|
|
32
|
-
expect(firstOn([1, 2, 3], [true, false, false], 0)).
|
|
33
|
-
expect(firstOn([1, 2, 3], [false, true, false], 0)).
|
|
34
|
-
expect(firstOn([1, 2, 3], [false, false, true], 0)).
|
|
35
|
-
expect(firstOn([1, 2, 3], [true, true, true], 0)).
|
|
36
|
-
expect(firstOn([], [], 0)).
|
|
32
|
+
expect(firstOn([1, 2, 3], [false, false, false], 0)).to.equal(0);
|
|
33
|
+
expect(firstOn([1, 2, 3], [true, false, false], 0)).to.equal(1);
|
|
34
|
+
expect(firstOn([1, 2, 3], [false, true, false], 0)).to.equal(2);
|
|
35
|
+
expect(firstOn([1, 2, 3], [false, false, true], 0)).to.equal(3);
|
|
36
|
+
expect(firstOn([1, 2, 3], [true, true, true], 0)).to.equal(1);
|
|
37
|
+
expect(firstOn([], [], 0)).to.equal(0);
|
|
37
38
|
});
|
|
38
39
|
it("can getDiffToNextOn", () => {
|
|
39
40
|
const values = [100, 200, 30];
|
|
40
|
-
expect(getDiffToNextOn(values, [false, false, false], 50)).
|
|
41
|
-
expect(getDiffToNextOn(values, [false, false, true], 50)).
|
|
42
|
-
expect(getDiffToNextOn(values, [false, true, false], 50)).
|
|
43
|
-
expect(getDiffToNextOn(values, [true, false, true], 50)).
|
|
44
|
-
expect(getDiffToNextOn(values, [true, true, false], 50)).
|
|
45
|
-
expect(getDiffToNextOn(values, [true, true, false])).
|
|
41
|
+
expect(getDiffToNextOn(values, [false, false, false], 50)).to.eql([50, 150, -20]);
|
|
42
|
+
expect(getDiffToNextOn(values, [false, false, true], 50)).to.eql([70, 170, -20]);
|
|
43
|
+
expect(getDiffToNextOn(values, [false, true, false], 50)).to.eql([-100, 150, -20]);
|
|
44
|
+
expect(getDiffToNextOn(values, [true, false, true], 50)).to.eql([70, 170, -20]);
|
|
45
|
+
expect(getDiffToNextOn(values, [true, true, false], 50)).to.eql([-100, 150, -20]);
|
|
46
|
+
expect(getDiffToNextOn(values, [true, true, false])).to.eql([-100, 170, 0]);
|
|
46
47
|
});
|
|
47
48
|
it("calculates savings for hours off", () => {
|
|
48
49
|
const values = [1, 10, 8, 5];
|
|
49
|
-
expect(getSavings(values, [true, true, true, true], 99)).
|
|
50
|
-
expect(getSavings(values, [false, false, false, false], 99)).
|
|
51
|
-
expect(getSavings(values, [false, true, false, true], 99)).
|
|
50
|
+
expect(getSavings(values, [true, true, true, true], 99)).to.eql([null, null, null, null]);
|
|
51
|
+
expect(getSavings(values, [false, false, false, false], 99)).to.eql([-98, -89, -91, -94]);
|
|
52
|
+
expect(getSavings(values, [false, true, false, true], 99)).to.eql([-9, null, 3, null]);
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
it("can count at end of array", () => {
|
|
55
|
-
expect(countAtEnd([], true)).
|
|
56
|
-
expect(countAtEnd([true], true)).
|
|
57
|
-
expect(countAtEnd([false], true)).
|
|
58
|
-
expect(countAtEnd([true], false)).
|
|
59
|
-
expect(countAtEnd([true, true], false)).
|
|
60
|
-
expect(countAtEnd([true, false], false)).
|
|
61
|
-
expect(countAtEnd([false, true], false)).
|
|
62
|
-
expect(countAtEnd([false, true], undefined)).
|
|
63
|
-
expect(countAtEnd([true, false], undefined)).
|
|
56
|
+
expect(countAtEnd([], true)).to.equal(0);
|
|
57
|
+
expect(countAtEnd([true], true)).to.equal(1);
|
|
58
|
+
expect(countAtEnd([false], true)).to.equal(0);
|
|
59
|
+
expect(countAtEnd([true], false)).to.equal(0);
|
|
60
|
+
expect(countAtEnd([true, true], false)).to.equal(0);
|
|
61
|
+
expect(countAtEnd([true, false], false)).to.equal(1);
|
|
62
|
+
expect(countAtEnd([false, true], false)).to.equal(0);
|
|
63
|
+
expect(countAtEnd([false, true], undefined)).to.equal(0);
|
|
64
|
+
expect(countAtEnd([true, false], undefined)).to.equal(0);
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
it("can make schedule", () => {
|
|
@@ -72,17 +73,17 @@ describe("utils", () => {
|
|
|
72
73
|
"2021-06-20T08:00:00+02:00",
|
|
73
74
|
"2021-06-20T09:00:00+02:00",
|
|
74
75
|
];
|
|
75
|
-
expect(makeSchedule(onOff, startTimes)).
|
|
76
|
+
expect(makeSchedule(onOff, startTimes)).to.eql([
|
|
76
77
|
{ time: "2021-06-20T05:00:00+02:00", value: false, countHours: 2 },
|
|
77
78
|
{ time: "2021-06-20T07:00:00+02:00", value: true, countHours: 2 },
|
|
78
79
|
{ time: "2021-06-20T09:00:00+02:00", value: false, countHours: 1 },
|
|
79
80
|
]);
|
|
80
|
-
expect(makeSchedule(onOff, startTimes, true)).
|
|
81
|
+
expect(makeSchedule(onOff, startTimes, true)).to.eql([
|
|
81
82
|
{ time: "2021-06-20T05:00:00+02:00", value: false, countHours: 2 },
|
|
82
83
|
{ time: "2021-06-20T07:00:00+02:00", value: true, countHours: 2 },
|
|
83
84
|
{ time: "2021-06-20T09:00:00+02:00", value: false, countHours: 1 },
|
|
84
85
|
]);
|
|
85
|
-
expect(makeSchedule(onOff, startTimes, false)).
|
|
86
|
+
expect(makeSchedule(onOff, startTimes, false)).to.eql([
|
|
86
87
|
{ time: "2021-06-20T05:00:00+02:00", value: false, countHours: 2 }, // Right???
|
|
87
88
|
{ time: "2021-06-20T07:00:00+02:00", value: true, countHours: 2 },
|
|
88
89
|
{ time: "2021-06-20T09:00:00+02:00", value: false, countHours: 1 },
|
|
@@ -90,19 +91,19 @@ describe("utils", () => {
|
|
|
90
91
|
});
|
|
91
92
|
|
|
92
93
|
it("can fill an array", () => {
|
|
93
|
-
expect(fillArray(false, 0)).
|
|
94
|
-
expect(fillArray(false, 2)).
|
|
95
|
-
expect(fillArray(true, 2)).
|
|
96
|
-
expect(fillArray(undefined, 2)).
|
|
97
|
-
expect(fillArray(true, 0)).
|
|
94
|
+
expect(fillArray(false, 0)).to.eql([]);
|
|
95
|
+
expect(fillArray(false, 2)).to.eql([false, false]);
|
|
96
|
+
expect(fillArray(true, 2)).to.eql([true, true]);
|
|
97
|
+
expect(fillArray(undefined, 2)).to.eql([]);
|
|
98
|
+
expect(fillArray(true, 0)).to.eql([]);
|
|
98
99
|
});
|
|
99
100
|
|
|
100
101
|
it("can compare dates", () => {
|
|
101
102
|
const date1 = "2021-06-20T01:50:00.000+02:00";
|
|
102
|
-
expect(isSameDate(date1, "2021-06-20T01:50:00.000+02:00")).
|
|
103
|
-
expect(isSameDate(date1, "2021-06-21T01:50:00.000+02:00")).
|
|
104
|
-
expect(isSameDate(date1, "2021-06-20")).
|
|
105
|
-
expect(isSameDate(date1, "2021-06-21")).
|
|
103
|
+
expect(isSameDate(date1, "2021-06-20T01:50:00.000+02:00")).to.equal(true);
|
|
104
|
+
expect(isSameDate(date1, "2021-06-21T01:50:00.000+02:00")).to.equal(false);
|
|
105
|
+
expect(isSameDate(date1, "2021-06-20")).to.equal(true);
|
|
106
|
+
expect(isSameDate(date1, "2021-06-21")).to.equal(false);
|
|
106
107
|
});
|
|
107
108
|
|
|
108
109
|
it("can extract plan for a date", () => {
|
|
@@ -196,7 +197,7 @@ describe("utils", () => {
|
|
|
196
197
|
},
|
|
197
198
|
],
|
|
198
199
|
};
|
|
199
|
-
expect(extractPlanForDate(plan, "2021-06-20T01:50:00.000+02:00")).
|
|
200
|
+
expect(extractPlanForDate(plan, "2021-06-20T01:50:00.000+02:00")).to.eql(part1);
|
|
200
201
|
});
|
|
201
202
|
it("Can make schedule from hours", () => {
|
|
202
203
|
const hours = cloneDeep(testResult.hours);
|
|
@@ -206,6 +207,6 @@ describe("utils", () => {
|
|
|
206
207
|
time: "2021-06-20T02:50:00.470+02:00",
|
|
207
208
|
value: false,
|
|
208
209
|
});
|
|
209
|
-
expect(resultToValidate).
|
|
210
|
+
expect(resultToValidate).to.eql(testResult.schedule);
|
|
210
211
|
});
|
|
211
212
|
});
|