node-red-contrib-power-saver 4.1.3 → 4.1.4

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/docs/.vuepress/client.js +7 -0
  3. package/docs/.vuepress/clientAppEnhance.js +1 -1
  4. package/docs/.vuepress/components/AdsenseAdd.vue +1 -1
  5. package/docs/.vuepress/config.js +31 -30
  6. package/docs/README.md +6 -0
  7. package/docs/changelog/README.md +4 -0
  8. package/docs/examples/example-grid-tariff-capacity-part.md +16 -5
  9. package/docs/privacy.md +17 -0
  10. package/examples/example-grid-tariff-capacity-flow.json +2 -2
  11. package/package.json +19 -18
  12. package/src/schedule-merger-functions.js +2 -1
  13. package/src/strategy-heat-capacitor-functions.js +38 -4
  14. package/src/strategy-heat-capacitor.html +2 -2
  15. package/src/strategy-heat-capacitor.js +94 -63
  16. package/test/commands-input-best-save.test.js +15 -15
  17. package/test/commands-input-lowest-price.test.js +15 -15
  18. package/test/commands-input-schedule-merger.test.js +11 -11
  19. package/test/data/heat-capacitor-prices-NaN-test.json +197 -0
  20. package/test/elvia.test.js +2 -2
  21. package/test/general-add-tariff-functions.test.js +6 -6
  22. package/test/general-add-tariff.test.js +7 -7
  23. package/test/mostSavedStrategy.test.js +17 -17
  24. package/test/receive-price-functions.test.js +9 -9
  25. package/test/receive-price.test.js +11 -11
  26. package/test/schedule-merger-functions.test.js +18 -28
  27. package/test/schedule-merger.test.js +17 -17
  28. package/test/send-config-input.test.js +13 -13
  29. package/test/strategy-best-save-overlap.test.js +2 -2
  30. package/test/strategy-best-save.test.js +28 -28
  31. package/test/strategy-fixed-schedule.test.js +5 -5
  32. package/test/strategy-heat-capacitor-node.test.js +115 -16
  33. package/test/strategy-heat-capacitor.test.js +8 -6
  34. package/test/strategy-lowest-price-3days.test.js +4 -4
  35. package/test/strategy-lowest-price-functions.test.js +13 -13
  36. package/test/strategy-lowest-price.test.js +34 -34
  37. package/test/utils.test.js +46 -45
@@ -1,4 +1,4 @@
1
- const expect = require("expect");
1
+ const expect = require("chai").expect;
2
2
  const { DateTime } = require("luxon");
3
3
  const { addTariffToPrices, buildAllHours } = require("../src/general-add-tariff-functions");
4
4
 
@@ -13,7 +13,7 @@ describe("general-add-tariff-functions", () => {
13
13
  fillResult(result, 6, 21, 10);
14
14
  fillResult(result, 22, 23, 11);
15
15
 
16
- expect(buildAllHours(console, periods)).toEqual(result);
16
+ expect(buildAllHours(console, periods)).to.eql(result);
17
17
  });
18
18
  it("can build all hours 0-22", () => {
19
19
  const periods = [
@@ -24,7 +24,7 @@ describe("general-add-tariff-functions", () => {
24
24
  fillResult(result, 0, 21, 10);
25
25
  fillResult(result, 22, 23, 11);
26
26
 
27
- expect(buildAllHours(console, periods)).toEqual(result);
27
+ expect(buildAllHours(console, periods)).to.eql(result);
28
28
  });
29
29
  it("can build all hours 22-23", () => {
30
30
  const periods = [
@@ -35,7 +35,7 @@ describe("general-add-tariff-functions", () => {
35
35
  fillResult(result, 0, 22, 10);
36
36
  fillResult(result, 23, 23, 11);
37
37
 
38
- expect(buildAllHours(console, periods)).toEqual(result);
38
+ expect(buildAllHours(console, periods)).to.eql(result);
39
39
  });
40
40
  it("can add tariff to prices", () => {
41
41
  const config = {
@@ -66,7 +66,7 @@ describe("general-add-tariff-functions", () => {
66
66
  };
67
67
  });
68
68
  addTariffToPrices(console, config, prices);
69
- expect(prices).toEqual(result);
69
+ expect(prices).to.eql(result);
70
70
  });
71
71
  it("pass through when out of period", () => {
72
72
  const config = {
@@ -95,7 +95,7 @@ describe("general-add-tariff-functions", () => {
95
95
  };
96
96
  });
97
97
  addTariffToPrices(console, config, prices);
98
- expect(prices).toEqual(result);
98
+ expect(prices).to.eql(result);
99
99
  });
100
100
  });
101
101
 
@@ -1,6 +1,6 @@
1
1
  const helper = require("node-red-node-test-helper");
2
2
  const addTariff = require("../src/general-add-tariff.js");
3
- const expect = require("expect");
3
+ const expect = require("chai").expect;
4
4
  const cloneDeep = require("lodash.clonedeep");
5
5
 
6
6
  const prices = {
@@ -50,7 +50,7 @@ describe("general-add-tariff node", function () {
50
50
  const flow = [{ id: "n1", type: "ps-general-add-tariff", name: "test name" }];
51
51
  helper.load(addTariff, flow, function () {
52
52
  const n1 = helper.getNode("n1");
53
- expect(n1).toHaveProperty("name", "test name");
53
+ expect(n1).to.have.property("name", "test name");
54
54
  done();
55
55
  });
56
56
  });
@@ -82,7 +82,7 @@ describe("general-add-tariff node", function () {
82
82
  const n1 = helper.getNode("n1");
83
83
  const n2 = helper.getNode("n2");
84
84
  n2.on("input", function (msg) {
85
- expect(msg).toHaveProperty("payload", result);
85
+ expect(msg).to.have.deep.property("payload", result);
86
86
  done();
87
87
  });
88
88
  const payload = cloneDeep(prices);
@@ -117,7 +117,7 @@ describe("general-add-tariff node", function () {
117
117
  const n1 = helper.getNode("n1");
118
118
  const n2 = helper.getNode("n2");
119
119
  n2.on("input", function (msg) {
120
- expect(msg).toHaveProperty("payload", result);
120
+ expect(msg).to.have.deep.property("payload", result);
121
121
  done();
122
122
  });
123
123
  const payload = cloneDeep(prices);
@@ -154,7 +154,7 @@ describe("general-add-tariff node", function () {
154
154
  const n1 = helper.getNode("n1");
155
155
  const n2 = helper.getNode("n2");
156
156
  n2.on("input", function (msg) {
157
- expect(msg).toHaveProperty("payload", result);
157
+ expect(msg).to.have.deep.property("payload", result);
158
158
  done();
159
159
  });
160
160
  n1.receive({ payload: prices });
@@ -187,7 +187,7 @@ describe("general-add-tariff node", function () {
187
187
  const n1 = helper.getNode("n1");
188
188
  const n2 = helper.getNode("n2");
189
189
  n2.on("input", function (msg) {
190
- expect(msg).toHaveProperty("payload", result);
190
+ expect(msg).to.have.deep.property("payload", result);
191
191
  done();
192
192
  });
193
193
  n1.receive({ payload: prices });
@@ -216,7 +216,7 @@ describe("general-add-tariff node", function () {
216
216
  const n1 = helper.getNode("n1");
217
217
  const n2 = helper.getNode("n2");
218
218
  n2.on("input", function (msg) {
219
- expect(msg).toHaveProperty("payload", result);
219
+ expect(msg).to.have.deep.property("payload", result);
220
220
  done();
221
221
  });
222
222
  n1.receive({ payload: prices });
@@ -1,31 +1,31 @@
1
- const expect = require("expect");
1
+ const expect = require("chai").expect;
2
2
  const { calculate, isOnOffSequencesOk } = require("../src/strategy-best-save-functions");
3
3
 
4
4
  const prices = require("./data/prices");
5
5
 
6
6
  describe("mostSavedStrategy", () => {
7
7
  it("evaluates onOff sequences correct", () => {
8
- expect(isOnOffSequencesOk([], 0, 0)).toBeTruthy();
9
- expect(isOnOffSequencesOk([true], 0, 0)).toBeTruthy();
10
- expect(isOnOffSequencesOk([false], 0, 0)).toBeFalsy();
11
- expect(isOnOffSequencesOk([true, false], 0, 0)).toBeFalsy();
12
- expect(isOnOffSequencesOk([true, false], 1, 0)).toBeTruthy();
8
+ expect(isOnOffSequencesOk([], 0, 0)).to.equal(true);
9
+ expect(isOnOffSequencesOk([true], 0, 0)).to.equal(true);
10
+ expect(isOnOffSequencesOk([false], 0, 0)).to.equal(false);
11
+ expect(isOnOffSequencesOk([true, false], 0, 0)).to.equal(false);
12
+ expect(isOnOffSequencesOk([true, false], 1, 0)).to.equal(true);
13
13
  const onOff = [true, true, false, false, false, true, true, false];
14
- expect(isOnOffSequencesOk(onOff, 3, 2)).toBeTruthy();
15
- expect(isOnOffSequencesOk(onOff, 4, 2)).toBeTruthy();
16
- expect(isOnOffSequencesOk(onOff, 2, 2)).toBeFalsy();
17
- expect(isOnOffSequencesOk(onOff, 3, 3)).toBeFalsy();
14
+ expect(isOnOffSequencesOk(onOff, 3, 2)).to.equal(true);
15
+ expect(isOnOffSequencesOk(onOff, 4, 2)).to.equal(true);
16
+ expect(isOnOffSequencesOk(onOff, 2, 2)).to.equal(false);
17
+ expect(isOnOffSequencesOk(onOff, 3, 3)).to.equal(false);
18
18
  });
19
19
 
20
20
  it("saves correct hours", () => {
21
21
  const values = prices.today.map((p) => p.value);
22
- expect(calculate(values, 3, 1, 0.001)).toEqual([true, true, false, false, true, false, false, false, true, true]);
23
- expect(calculate(values, 3, 1, 0.001)).toEqual([true, true, false, false, true, false, false, false, true, true]);
24
- expect(calculate(values, 2, 1, 0.001)).toEqual([true, true, true, false, false, true, false, false, true, true]);
25
- expect(calculate(values, 2, 3, 0.001)).toEqual([true, true, true, false, true, true, false, false, true, true]);
26
- expect(calculate(values, 2, 0, 0.001)).toEqual([true, true, true, false, false, true, false, false, true, true]);
22
+ expect(calculate(values, 3, 1, 0.001)).to.eql([true, true, false, false, true, false, false, false, true, true]);
23
+ expect(calculate(values, 3, 1, 0.001)).to.eql([true, true, false, false, true, false, false, false, true, true]);
24
+ expect(calculate(values, 2, 1, 0.001)).to.eql([true, true, true, false, false, true, false, false, true, true]);
25
+ expect(calculate(values, 2, 3, 0.001)).to.eql([true, true, true, false, true, true, false, false, true, true]);
26
+ expect(calculate(values, 2, 0, 0.001)).to.eql([true, true, true, false, false, true, false, false, true, true]);
27
27
  const values2 = prices.tomorrow.map((p) => p.value);
28
- expect(calculate(values2, 2, 1, 0.001, true, 1)).toEqual([
28
+ expect(calculate(values2, 2, 1, 0.001, true, 1)).to.eql([
29
29
  false,
30
30
  false,
31
31
  true,
@@ -37,7 +37,7 @@ describe("mostSavedStrategy", () => {
37
37
  true,
38
38
  true,
39
39
  ]);
40
- expect(calculate(values2, 2, 1, 0.001, false, 1)).toEqual([
40
+ expect(calculate(values2, 2, 1, 0.001, false, 1)).to.eql([
41
41
  true,
42
42
  false,
43
43
  true,
@@ -1,4 +1,4 @@
1
- const expect = require("expect");
1
+ const expect = require("chai").expect;
2
2
  const { convertMsg } = require("../src/receive-price-functions");
3
3
 
4
4
  describe("receive-price-functions", () => {
@@ -138,34 +138,34 @@ describe("receive-price-functions", () => {
138
138
  },
139
139
  };
140
140
 
141
- expect(convertMsg(msgStd)).toEqual({ source: "Other", ...msgStd.payload });
142
- expect(convertMsg(msgTibber)).toEqual({
141
+ expect(convertMsg(msgStd)).to.eql({ source: "Other", ...msgStd.payload });
142
+ expect(convertMsg(msgTibber)).to.eql({
143
143
  source: "Tibber",
144
144
  ...msgStd.payload,
145
145
  });
146
- expect(convertMsg(msgTibberSingle)).toEqual({
146
+ expect(convertMsg(msgTibberSingle)).to.eql({
147
147
  source: "Tibber",
148
148
  ...msgStd.payload,
149
149
  });
150
- expect(convertMsg(msgNordpool)).toEqual({
150
+ expect(convertMsg(msgNordpool)).to.eql({
151
151
  source: "Nordpool",
152
152
  ...msgStd.payload,
153
153
  });
154
154
  msgTibber.payload.viewer.homes[0].currentSubscription.priceInfo.tomorrow = [];
155
- expect(convertMsg(msgTibber)).toEqual({
155
+ expect(convertMsg(msgTibber)).to.eql({
156
156
  source: "Tibber",
157
157
  ...msgStdTodayOnly.payload,
158
158
  });
159
159
  msgNordpool.data.new_state.attributes.raw_tomorrow = [];
160
- expect(convertMsg(msgNordpool)).toEqual({
160
+ expect(convertMsg(msgNordpool)).to.eql({
161
161
  source: "Nordpool",
162
162
  ...msgStdTodayOnly.payload,
163
163
  });
164
- expect(convertMsg(msgNordpoolTomorrowNull)).toEqual({
164
+ expect(convertMsg(msgNordpoolTomorrowNull)).to.eql({
165
165
  source: "Nordpool",
166
166
  ...msgStdTodayOnly.payload,
167
167
  });
168
- expect(convertMsg(msgStdTodayOnly)).toEqual({
168
+ expect(convertMsg(msgStdTodayOnly)).to.eql({
169
169
  source: "Other",
170
170
  ...msgStdTodayOnly.payload,
171
171
  });
@@ -1,6 +1,6 @@
1
1
  const helper = require("node-red-node-test-helper");
2
2
  const receivePrices = require("../src/receive-price.js");
3
- const expect = require("expect");
3
+ const expect = require("chai").expect;
4
4
 
5
5
  helper.init(require.resolve("node-red"));
6
6
 
@@ -19,7 +19,7 @@ describe("receive-price node", function () {
19
19
  const flow = [{ id: "n1", type: "ps-receive-price", name: "test name" }];
20
20
  helper.load(receivePrices, flow, function () {
21
21
  const n1 = helper.getNode("n1");
22
- expect(n1).toHaveProperty("name", "test name");
22
+ expect(n1).to.have.property("name", "test name");
23
23
  done();
24
24
  });
25
25
  });
@@ -41,7 +41,7 @@ describe("receive-price node", function () {
41
41
  const n1 = helper.getNode("n1");
42
42
  const n2 = helper.getNode("n2");
43
43
  n2.on("input", function (msg) {
44
- expect(msg).toHaveProperty("payload", convertedPrices);
44
+ expect(msg).to.have.deep.property("payload", convertedPrices);
45
45
  done();
46
46
  });
47
47
  n1.receive(tibberPrices);
@@ -65,7 +65,7 @@ describe("receive-price node", function () {
65
65
  const n1 = helper.getNode("n1");
66
66
  const n2 = helper.getNode("n2");
67
67
  n2.on("input", function (msg) {
68
- expect(msg).toHaveProperty("payload", convertedPrices);
68
+ expect(msg).to.have.deep.property("payload", convertedPrices);
69
69
  done();
70
70
  });
71
71
  n1.receive(tibberPrices);
@@ -89,7 +89,7 @@ describe("receive-price node", function () {
89
89
  const n1 = helper.getNode("n1");
90
90
  const n2 = helper.getNode("n2");
91
91
  n2.on("input", function (msg) {
92
- expect(msg).toHaveProperty("payload", convertedPrices);
92
+ expect(msg).to.have.deep.property("payload", convertedPrices);
93
93
  done();
94
94
  });
95
95
  n1.receive(nordpoolPrices);
@@ -113,8 +113,8 @@ describe("receive-price node", function () {
113
113
  const n1 = helper.getNode("n1");
114
114
  const n2 = helper.getNode("n2");
115
115
  n2.on("input", function (msg) {
116
- expect(msg.payload.priceData.length).toEqual(48);
117
- expect(msg.payload.source).toEqual("Nordpool");
116
+ expect(msg.payload.priceData.length).to.equal(48);
117
+ expect(msg.payload.source).to.equal("Nordpool");
118
118
  done();
119
119
  });
120
120
  n1.receive({ payload: nordpoolPrices.payload, data: nordpoolPrices.data });
@@ -135,8 +135,8 @@ describe("receive-price node", function () {
135
135
  const n1 = helper.getNode("n1");
136
136
  const n2 = helper.getNode("n2");
137
137
  n2.on("input", function (msg) {
138
- expect(msg.payload.priceData.length).toEqual(48);
139
- expect(msg.payload.source).toEqual("Nordpool");
138
+ expect(msg.payload.priceData.length).to.equal(48);
139
+ expect(msg.payload.source).to.equal("Nordpool");
140
140
  done();
141
141
  });
142
142
  n1.receive({ payload: nordpoolPrices.payload });
@@ -157,8 +157,8 @@ describe("receive-price node", function () {
157
157
  const n1 = helper.getNode("n1");
158
158
  const n2 = helper.getNode("n2");
159
159
  n2.on("input", function (msg) {
160
- expect(msg.payload.priceData.length).toEqual(48);
161
- expect(msg.payload.source).toEqual("Nordpool");
160
+ expect(msg.payload.priceData.length).to.equal(48);
161
+ expect(msg.payload.source).to.equal("Nordpool");
162
162
  done();
163
163
  });
164
164
  n1.receive(nordpoolPrices);
@@ -1,5 +1,5 @@
1
1
  const { DateTime } = require("luxon");
2
- const expect = require("expect");
2
+ const expect = require("chai").expect;
3
3
  const { validateSchedule, saveSchedule, mergeSchedules, runSchedule } = require("../src/schedule-merger-functions");
4
4
  const bestSaveResult = require("./data/best-save-result.json");
5
5
  const mergeData = require("./data/merge-schedule-data.js");
@@ -12,15 +12,14 @@ describe("schedule-merger-functions", () => {
12
12
  msg.payload.strategyNodeId = "1";
13
13
  msg.payload.hours[0].onOff = false;
14
14
  saveSchedule(node, msg);
15
- expect(node.context().get()["1"]).toEqual(msg.payload);
15
+ expect(node.context().get()["1"]).to.eql(msg.payload);
16
16
 
17
17
  msg.payload.strategyNodeId = "2";
18
18
  msg.payload.hours[0].onOff = true;
19
19
  saveSchedule(node, msg);
20
- expect(node.context().get()["1"]).toEqual(msg.payload);
21
- expect(node.context().get()["2"]).toEqual(msg.payload);
22
- expect(node.context().get()["1"].hours.onOff).toBeFalsy;
23
- expect(node.context().get()["2"].hours.onOff).toBeTruthy;
20
+ expect(node.context().get()["2"]).to.eql(msg.payload);
21
+ expect(node.context().get()["1"].hours[0].onOff).to.equal(false);
22
+ expect(node.context().get()["2"].hours[0].onOff).to.equal(true);
24
23
  });
25
24
 
26
25
  it("mergeSchedule", () => {
@@ -36,49 +35,40 @@ describe("schedule-merger-functions", () => {
36
35
 
37
36
  let node = useNodeMock();
38
37
  saveSchedule(node, messages.allOff);
39
- expect(mergeSchedules(node, "OR").map((h) => h.onOff)).toEqual([false, false, false, false, false]);
38
+ expect(mergeSchedules(node, "OR").map((h) => h.onOff)).to.eql([false, false, false, false, false]);
40
39
  saveSchedule(node, messages.allOn);
41
- expect(mergeSchedules(node, "OR").map((h) => h.onOff)).toEqual([true, true, true, true, true]);
42
- expect(mergeSchedules(node, "AND").map((h) => h.onOff)).toEqual([false, false, false, false, false]);
40
+ expect(mergeSchedules(node, "OR").map((h) => h.onOff)).to.eql([true, true, true, true, true]);
41
+ expect(mergeSchedules(node, "AND").map((h) => h.onOff)).to.eql([false, false, false, false, false]);
43
42
 
44
43
  node = useNodeMock();
45
44
  saveSchedule(node, messages.someOn);
46
45
  saveSchedule(node, messages.allOn);
47
- expect(mergeSchedules(node, "OR").map((h) => h.onOff)).toEqual([true, true, true, true, true]);
48
- expect(mergeSchedules(node, "AND").map((h) => h.onOff)).toEqual([true, false, true, false, true]);
46
+ expect(mergeSchedules(node, "OR").map((h) => h.onOff)).to.eql([true, true, true, true, true]);
47
+ expect(mergeSchedules(node, "AND").map((h) => h.onOff)).to.eql([true, false, true, false, true]);
49
48
 
50
49
  node = useNodeMock();
51
50
  saveSchedule(node, messages.someOn);
52
51
  saveSchedule(node, messages.allOff);
53
- expect(mergeSchedules(node, "OR").map((h) => h.onOff)).toEqual([true, false, true, false, true]);
54
- expect(mergeSchedules(node, "AND").map((h) => h.onOff)).toEqual([false, false, false, false, false]);
52
+ expect(mergeSchedules(node, "OR").map((h) => h.onOff)).to.eql([true, false, true, false, true]);
53
+ expect(mergeSchedules(node, "AND").map((h) => h.onOff)).to.eql([false, false, false, false, false]);
55
54
  saveSchedule(node, messages.hourLater);
56
- expect(mergeSchedules(node, "OR").map((h) => h.onOff)).toEqual([true, false, false, true, true]);
57
- expect(mergeSchedules(node, "AND").map((h) => h.onOff)).toEqual([true, false, false, true, true]);
55
+ expect(mergeSchedules(node, "OR").map((h) => h.onOff)).to.eql([true, false, false, true, true]);
56
+ expect(mergeSchedules(node, "AND").map((h) => h.onOff)).to.eql([true, false, false, true, true]);
58
57
 
59
58
  saveSchedule(node, messages.someOn);
60
59
  saveSchedule(node, messages.allOff);
61
- expect(mergeSchedules(node, "OR").map((h) => h.onOff)).toEqual([true, false, true, false, true]);
62
- expect(mergeSchedules(node, "AND").map((h) => h.onOff)).toEqual([false, false, false, false, false]);
60
+ expect(mergeSchedules(node, "OR").map((h) => h.onOff)).to.eql([true, false, true, false, true]);
61
+ expect(mergeSchedules(node, "AND").map((h) => h.onOff)).to.eql([false, false, false, false, false]);
63
62
 
64
63
  node = useNodeMock();
65
64
  saveSchedule(node, messages.someOn);
66
65
  saveSchedule(node, messages.lessHours);
67
- expect(mergeSchedules(node, "OR").map((h) => h.onOff)).toEqual([false, true, false]);
66
+ expect(mergeSchedules(node, "OR").map((h) => h.onOff)).to.eql([false, true, false]);
68
67
 
69
68
  node = useNodeMock();
70
69
  saveSchedule(node, messages.someOn);
71
70
  saveSchedule(node, messages.moreHours);
72
- expect(mergeSchedules(node, "OR").map((h) => h.onOff)).toEqual([
73
- true,
74
- true,
75
- false,
76
- false,
77
- false,
78
- true,
79
- true,
80
- false,
81
- ]);
71
+ expect(mergeSchedules(node, "OR").map((h) => h.onOff)).to.eql([true, true, false, false, false, true, true, false]);
82
72
  });
83
73
  });
84
74
 
@@ -1,4 +1,4 @@
1
- const expect = require("expect");
1
+ const expect = require("chai").expect;
2
2
  const helper = require("node-red-node-test-helper");
3
3
  const scheduleMerger = require("../src/schedule-merger.js");
4
4
  const { equalHours } = require("./test-utils");
@@ -22,7 +22,7 @@ describe("schedule-merger node", function () {
22
22
  const flow = [{ id: "n1", type: "ps-schedule-merger", name: "test name" }];
23
23
  helper.load(scheduleMerger, flow, function () {
24
24
  const n1 = helper.getNode("n1");
25
- expect(n1).toHaveProperty("name", "test name");
25
+ expect(n1).to.have.property("name", "test name");
26
26
  done();
27
27
  });
28
28
  });
@@ -33,7 +33,7 @@ describe("schedule-merger node", function () {
33
33
  const n1 = helper.getNode("n1");
34
34
  const n2 = helper.getNode("n2");
35
35
  n2.on("input", function (msg) {
36
- expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).toBeTruthy();
36
+ expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
37
37
  n1.warn.should.not.be.called;
38
38
  done();
39
39
  });
@@ -48,10 +48,10 @@ describe("schedule-merger node", function () {
48
48
  const n1 = helper.getNode("n1");
49
49
  const n2 = helper.getNode("n2");
50
50
  n2.on("input", function (msg) {
51
- expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).toBeTruthy();
52
- expect(msg.payload.schedule.length).toBe(6);
53
- expect(msg.payload.schedule[5].value).toBeFalsy();
54
- expect(msg.payload.schedule[5].countHours).toBeNull();
51
+ expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
52
+ expect(msg.payload.schedule.length).to.equal(6);
53
+ expect(msg.payload.schedule[5].value).to.equal(false);
54
+ expect(msg.payload.schedule[5].countHours).to.equal(null);
55
55
  n1.warn.should.not.be.called;
56
56
  done();
57
57
  });
@@ -66,8 +66,8 @@ describe("schedule-merger 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(equalHours(allOn, msg.payload.hours, ["price", "onOff", "start"])).toBeTruthy();
70
- expect(msg.payload.schedule.length).toBe(1);
69
+ expect(equalHours(allOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
70
+ expect(msg.payload.schedule.length).to.equal(1);
71
71
  n1.warn.should.not.be.called;
72
72
  done();
73
73
  });
@@ -82,10 +82,10 @@ describe("schedule-merger node", function () {
82
82
  const n1 = helper.getNode("n1");
83
83
  const n2 = helper.getNode("n2");
84
84
  n2.on("input", function (msg) {
85
- expect(equalHours(allOff, msg.payload.hours, ["price", "onOff", "start"])).toBeTruthy();
86
- expect(msg.payload.schedule.length).toBe(2);
87
- expect(msg.payload.schedule[1].value).toBeTruthy();
88
- expect(msg.payload.schedule[1].countHours).toBeNull();
85
+ expect(equalHours(allOff, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
86
+ expect(msg.payload.schedule.length).to.equal(2);
87
+ expect(msg.payload.schedule[1].value).to.equal(true);
88
+ expect(msg.payload.schedule[1].countHours).to.equal(null);
89
89
  n1.warn.should.not.be.called;
90
90
  done();
91
91
  });
@@ -100,8 +100,8 @@ describe("schedule-merger node", function () {
100
100
  const n1 = helper.getNode("n1");
101
101
  const n2 = helper.getNode("n2");
102
102
  n2.on("input", function (msg) {
103
- expect(equalHours(allOn, msg.payload.hours, ["price", "onOff", "start"])).toBeTruthy();
104
- expect(msg.payload.schedule.length).toBe(1);
103
+ expect(equalHours(allOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
104
+ expect(msg.payload.schedule.length).to.equal(1);
105
105
  n1.warn.should.not.be.called;
106
106
  done();
107
107
  });
@@ -117,8 +117,8 @@ describe("schedule-merger node", function () {
117
117
  const n1 = helper.getNode("n1");
118
118
  const n2 = helper.getNode("n2");
119
119
  n2.on("input", function (msg) {
120
- expect(equalHours(allOff, msg.payload.hours, ["price", "onOff", "start"])).toBeTruthy();
121
- expect(msg.payload.schedule.length).toBe(1);
120
+ expect(equalHours(allOff, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
121
+ expect(msg.payload.schedule.length).to.equal(1);
122
122
  n1.warn.should.not.be.called;
123
123
  done();
124
124
  });
@@ -1,4 +1,4 @@
1
- const expect = require("expect");
1
+ const expect = require("chai").expect;
2
2
  const helper = require("node-red-node-test-helper");
3
3
  const bestSave = require("../src/strategy-best-save.js");
4
4
  const { DateTime } = require("luxon");
@@ -32,17 +32,17 @@ describe("send config as input", () => {
32
32
  switch (pass) {
33
33
  case 1:
34
34
  pass++;
35
- expect(equalPlan(result, msg.payload)).toBeTruthy();
35
+ expect(equalPlan(result, msg.payload)).to.equal(true);
36
36
  n1.receive({ payload: { config: { minSaving: 1.0 } } });
37
37
  break;
38
38
  case 2:
39
39
  pass++;
40
- expect(msg.payload.schedule.length).toEqual(2);
40
+ expect(msg.payload.schedule.length).to.equal(2);
41
41
  n1.receive({ payload: makePayload(prices, testPlan.time) });
42
42
  break;
43
43
  case 3:
44
44
  pass++;
45
- expect(msg.payload.schedule.length).toEqual(2);
45
+ expect(msg.payload.schedule.length).to.equal(2);
46
46
  done();
47
47
  }
48
48
  });
@@ -60,7 +60,7 @@ describe("send config as input", () => {
60
60
  switch (pass) {
61
61
  case 1:
62
62
  pass++;
63
- expect(equalPlan(result, msg.payload)).toBeTruthy();
63
+ expect(equalPlan(result, msg.payload)).to.equal(true);
64
64
  n1.receive({
65
65
  payload: {
66
66
  config: { minHoursOnAfterMaxSequenceSaved: 5 },
@@ -71,14 +71,14 @@ describe("send config as input", () => {
71
71
  case 2:
72
72
  pass++;
73
73
  reconfigResult.config.minHoursOnAfterMaxSequenceSaved = 5;
74
- expect(equalPlan(reconfigResult, msg.payload)).toBeTruthy();
74
+ expect(equalPlan(reconfigResult, msg.payload)).to.equal(true);
75
75
  const payload = makePayload(prices, testPlan.time);
76
76
  payload.time = changeTime;
77
77
  n1.receive({ payload });
78
78
  break;
79
79
  case 3:
80
80
  pass++;
81
- expect(equalPlan(reconfigResult, msg.payload)).toBeTruthy();
81
+ expect(equalPlan(reconfigResult, msg.payload)).to.equal(true);
82
82
  done();
83
83
  }
84
84
  });
@@ -95,7 +95,7 @@ describe("send config as input", () => {
95
95
  switch (pass) {
96
96
  case 1:
97
97
  pass++;
98
- expect(equalPlan(result, msg.payload)).toBeTruthy();
98
+ expect(equalPlan(result, msg.payload)).to.equal(true);
99
99
  n1.receive({ payload: makePayloadWithConfigAndPrices(prices, testPlan.time) });
100
100
  break;
101
101
  case 2:
@@ -106,7 +106,7 @@ describe("send config as input", () => {
106
106
  const planSum = msg.payload.hours.reduce((prev, h) => {
107
107
  return prev + h.price;
108
108
  }, 0);
109
- expect(Math.round(planSum)).toEqual(Math.round(priceSum * 2));
109
+ expect(Math.round(planSum)).to.equal(Math.round(priceSum * 2));
110
110
  done();
111
111
  }
112
112
  });
@@ -130,8 +130,8 @@ describe("send config as input", () => {
130
130
  if (pass === 1) {
131
131
  setTimeout(() => {
132
132
  console.log("countOn = " + countOn + ", countOff = " + countOff);
133
- expect(countOn).toEqual(2);
134
- expect(countOff).toEqual(2);
133
+ expect(countOn).to.equal(2);
134
+ expect(countOff).to.equal(2);
135
135
  n1.status.should.be.calledWithExactly({ fill: "yellow", shape: "dot", text: "Override on" });
136
136
  done();
137
137
  }, 900);
@@ -139,14 +139,14 @@ describe("send config as input", () => {
139
139
  });
140
140
  n3.on("input", function (msg) {
141
141
  countOn++;
142
- expect(msg).toHaveProperty("payload", true);
142
+ expect(msg).to.have.deep.property("payload", true);
143
143
  if (countOn === 2) {
144
144
  n1.receive({ payload: { config: { override: "on" }, time } });
145
145
  }
146
146
  });
147
147
  n4.on("input", function (msg) {
148
148
  countOff++;
149
- expect(msg).toHaveProperty("payload", false);
149
+ expect(msg).to.have.deep.property("payload", false);
150
150
  if (countOff === 1) {
151
151
  n1.receive({ payload: { config: { override: "on" }, name: "wrong name" }, time });
152
152
  }
@@ -1,6 +1,6 @@
1
1
  const cloneDeep = require("lodash.clonedeep");
2
2
  const { DateTime } = require("luxon");
3
- const expect = require("expect");
3
+ const expect = require("chai").expect;
4
4
  const helper = require("node-red-node-test-helper");
5
5
  const bestSave = require("../src/strategy-best-save.js");
6
6
  const prices = require("./data/best-save-overlap-prices.json");
@@ -34,7 +34,7 @@ describe("ps-strategy-best-save overlapping savings", function () {
34
34
  const n1 = helper.getNode("n1");
35
35
  const n2 = helper.getNode("n2");
36
36
  n2.on("input", function (msg) {
37
- expect(equalPlan(expected, msg.payload)).toBeTruthy();
37
+ expect(equalPlan(expected, msg.payload)).to.equal(true);
38
38
  n1.warn.should.not.be.called;
39
39
  setTimeout(() => {
40
40
  done();