From 6ea25b6d4733fa56109a4d6f719b06f781e60183 Mon Sep 17 00:00:00 2001 From: janh Date: Fri, 26 May 2023 14:01:14 +0200 Subject: [PATCH] fix(datapoints-graph): updating tests --- .../charts/echarts-options.service.spec.ts | 14 +++++++++++--- .../charts/echarts-options.service.ts | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/datapoints-graph/charts/echarts-options.service.spec.ts b/src/datapoints-graph/charts/echarts-options.service.spec.ts index 121422fa..6a780e54 100644 --- a/src/datapoints-graph/charts/echarts-options.service.spec.ts +++ b/src/datapoints-graph/charts/echarts-options.service.spec.ts @@ -314,6 +314,7 @@ describe('EchartsOptionsService', () => { data: [[XAxisValue, -10]], itemStyle: { color: 'blue' }, datapointLabel: 'c8y_Temperature → T', + datapointUnit: 'C', }, { id: dp3.__target.id + dp3.fragment + dp3.series, @@ -323,6 +324,7 @@ describe('EchartsOptionsService', () => { ], itemStyle: { color: 'red' }, datapointLabel: 'c8y_Temperature → T', + datapointUnit: 'C', }, ], }); @@ -338,7 +340,7 @@ describe('EchartsOptionsService', () => { const tooltipInnerHtml = tooltipFormatter(params, null); // then expect(tooltipInnerHtml).toBe( - `2023-03-20T10:10:00.000Z
c8y_Temperature → T: -10
2023-03-20T10:10:00.000Z
c8y_Temperature → T: 2
2023-03-20T10:09:00.000Z
` + `2023-03-20T10:10:00.000Z
c8y_Temperature → T: -10 C
2023-03-20T10:10:00.000Z
c8y_Temperature → T: 2 C
2023-03-20T10:09:00.000Z
` ); }); @@ -355,24 +357,28 @@ describe('EchartsOptionsService', () => { data: [[XAxisValue, -10]], itemStyle: { color: 'blue' }, datapointLabel: 'c8y_Temperature → T', + datapointUnit: 'C', }, { id: dp2.__target.id + dp2.fragment + dp2.series + '/min', data: [[oneMinuteAfterXAxisValue, -10]], itemStyle: { color: 'blue' }, datapointLabel: 'c8y_Temperature → T', + datapointUnit: 'C', }, { id: dp2.__target.id + dp2.fragment + dp2.series + '/max', data: [[oneMinuteAfterXAxisValue, 10]], itemStyle: { color: 'blue' }, datapointLabel: 'c8y_Temperature → T', + datapointUnit: 'C', }, { id: dp3.__target.id + dp3.fragment + dp3.series, data: [[oneMinuteAfterXAxisValue, 0]], itemStyle: { color: 'red' }, datapointLabel: 'c8y_Temperature → T', + datapointUnit: 'C', }, ], }); @@ -388,7 +394,7 @@ describe('EchartsOptionsService', () => { const tooltipInnerHtml = tooltipFormatter(params, null); // then expect(tooltipInnerHtml).toBe( - `2023-03-20T10:10:00.000Z
c8y_Temperature → T: -10
2023-03-20T10:10:00.000Z
` + `2023-03-20T10:10:00.000Z
c8y_Temperature → T: -10 C
2023-03-20T10:10:00.000Z
` ); }); @@ -402,12 +408,14 @@ describe('EchartsOptionsService', () => { data: [[XAxisValue, -10]], itemStyle: { color: 'blue' }, datapointLabel: 'c8y_Temperature → T', + datapointUnit: 'C', }, { id: dp1.__target.id + dp1.fragment + dp1.series + '/max', data: [[XAxisValue, 10]], itemStyle: { color: 'blue' }, datapointLabel: 'c8y_Temperature → T', + datapointUnit: 'C', }, ], }); @@ -423,7 +431,7 @@ describe('EchartsOptionsService', () => { const tooltipInnerHtml = tooltipFormatter(params, null); // then expect(tooltipInnerHtml).toBe( - `2023-03-20T10:10:00.000Z
c8y_Temperature → T: -10 — 10
2023-03-20T10:10:00.000Z
` + `2023-03-20T10:10:00.000Z
c8y_Temperature → T: -10 — 10 C
2023-03-20T10:10:00.000Z
` ); }); }); diff --git a/src/datapoints-graph/charts/echarts-options.service.ts b/src/datapoints-graph/charts/echarts-options.service.ts index b03a36c6..2db219aa 100644 --- a/src/datapoints-graph/charts/echarts-options.service.ts +++ b/src/datapoints-graph/charts/echarts-options.service.ts @@ -182,7 +182,7 @@ export class EchartsOptionsService { ); value = `${minValue[1]} — ${maxValue[1]}` + - ` ${series.datapointUnit}` + + (series.datapointUnit ? ` ${series.datapointUnit}` : '') + `
${this.datePipe.transform( minValue[0] )}
`; @@ -199,7 +199,7 @@ export class EchartsOptionsService { } value = seriesValue[1]?.toString() + - ` ${series.datapointUnit}` + + (series.datapointUnit ? ` ${series.datapointUnit}` : '') + `
${this.datePipe.transform( seriesValue[0] )}
`;