summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/node.d/fronius.chart.spec.js2
-rw-r--r--tests/node.d/fronius.parse.spec.js27
2 files changed, 28 insertions, 1 deletions
diff --git a/tests/node.d/fronius.chart.spec.js b/tests/node.d/fronius.chart.spec.js
index 5404e82f..2d2b57cd 100644
--- a/tests/node.d/fronius.chart.spec.js
+++ b/tests/node.d/fronius.chart.spec.js
@@ -68,7 +68,7 @@ describe("fronius chart creation", function () {
expect(result.type).toBe(netdata.chartTypes.area);
expect(result.family).toBe("autonomy");
expect(result.context).toBe("fronius.autonomy");
- expect(Object.keys(result.dimensions).length).toBe(2);
+ expect(Object.keys(result.dimensions).length).toBe(3);
expect(result.dimensions[subject.autonomyId].name).toBe("autonomy");
expect(result.dimensions[subject.consumptionSelfId].name).toBe("self_consumption");
});
diff --git a/tests/node.d/fronius.parse.spec.js b/tests/node.d/fronius.parse.spec.js
index 9c371ad9..0dbfa030 100644
--- a/tests/node.d/fronius.parse.spec.js
+++ b/tests/node.d/fronius.parse.spec.js
@@ -234,6 +234,33 @@ describe("fronius parsing for autonomy", function () {
expect(result.name).toBe(subject.consumptionSelfId);
expect(result.value).toBe(0);
});
+
+ it("should return 0 for solarConsumption if PV is null", function () {
+ site.P_PV = null;
+ site.P_Load = -1000;
+ var result = subject.parseAutonomyChart(service, site).dimensions[2];
+
+ expect(result.name).toBe(subject.solarConsumptionId);
+ expect(result.value).toBe(0);
+ });
+
+ it("should return 100 for solarConsumption if Load is higher than solar power", function () {
+ site.P_PV = 500;
+ site.P_Load = -1500;
+ var result = subject.parseAutonomyChart(service, site).dimensions[2];
+
+ expect(result.name).toBe(subject.solarConsumptionId);
+ expect(result.value).toBe(100);
+ });
+
+ it("should return 50 for solarConsumption if Load is half than solar power", function () {
+ site.P_PV = 3000;
+ site.P_Load = -1500;
+ var result = subject.parseAutonomyChart(service, site).dimensions[2];
+
+ expect(result.name).toBe(subject.solarConsumptionId);
+ expect(result.value).toBe(50);
+ });
});
describe("fronius parsing for energy", function () {