Skip to content

Commit

Permalink
fix(datapoints-graph): updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janh committed May 26, 2023
1 parent 765e944 commit 6ea25b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/datapoints-graph/charts/echarts-options.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -323,6 +324,7 @@ describe('EchartsOptionsService', () => {
],
itemStyle: { color: 'red' },
datapointLabel: 'c8y_Temperature → T',
datapointUnit: 'C',
},
],
});
Expand All @@ -338,7 +340,7 @@ describe('EchartsOptionsService', () => {
const tooltipInnerHtml = tooltipFormatter(params, null);
// then
expect(tooltipInnerHtml).toBe(
`2023-03-20T10:10:00.000Z<br/><span style='display: inline-block; background-color: blue ; height: 12px; width: 12px; border-radius: 50%; margin-right: 4px;'></span><strong>c8y_Temperature → T: </strong>-10<div style="font-size: 11px">2023-03-20T10:10:00.000Z</div><span style='display: inline-block; background-color: red ; height: 12px; width: 12px; border-radius: 50%; margin-right: 4px;'></span><strong>c8y_Temperature → T: </strong>2<div style="font-size: 11px">2023-03-20T10:09:00.000Z</div>`
`2023-03-20T10:10:00.000Z<br/><span style='display: inline-block; background-color: blue ; height: 12px; width: 12px; border-radius: 50%; margin-right: 4px;'></span><strong>c8y_Temperature → T: </strong>-10 C<div style="font-size: 11px">2023-03-20T10:10:00.000Z</div><span style='display: inline-block; background-color: red ; height: 12px; width: 12px; border-radius: 50%; margin-right: 4px;'></span><strong>c8y_Temperature → T: </strong>2 C<div style="font-size: 11px">2023-03-20T10:09:00.000Z</div>`
);
});

Expand All @@ -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',
},
],
});
Expand All @@ -388,7 +394,7 @@ describe('EchartsOptionsService', () => {
const tooltipInnerHtml = tooltipFormatter(params, null);
// then
expect(tooltipInnerHtml).toBe(
`2023-03-20T10:10:00.000Z<br/><span style='display: inline-block; background-color: blue ; height: 12px; width: 12px; border-radius: 50%; margin-right: 4px;'></span><strong>c8y_Temperature → T: </strong>-10<div style="font-size: 11px">2023-03-20T10:10:00.000Z</div>`
`2023-03-20T10:10:00.000Z<br/><span style='display: inline-block; background-color: blue ; height: 12px; width: 12px; border-radius: 50%; margin-right: 4px;'></span><strong>c8y_Temperature → T: </strong>-10 C<div style="font-size: 11px">2023-03-20T10:10:00.000Z</div>`
);
});

Expand All @@ -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',
},
],
});
Expand All @@ -423,7 +431,7 @@ describe('EchartsOptionsService', () => {
const tooltipInnerHtml = tooltipFormatter(params, null);
// then
expect(tooltipInnerHtml).toBe(
`2023-03-20T10:10:00.000Z<br/><span style='display: inline-block; background-color: blue ; height: 12px; width: 12px; border-radius: 50%; margin-right: 4px;'></span><strong>c8y_Temperature → T: </strong>-10 — 10<div style="font-size: 11px">2023-03-20T10:10:00.000Z</div>`
`2023-03-20T10:10:00.000Z<br/><span style='display: inline-block; background-color: blue ; height: 12px; width: 12px; border-radius: 50%; margin-right: 4px;'></span><strong>c8y_Temperature → T: </strong>-10 — 10 C<div style="font-size: 11px">2023-03-20T10:10:00.000Z</div>`
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/datapoints-graph/charts/echarts-options.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class EchartsOptionsService {
);
value =
`${minValue[1]}${maxValue[1]}` +
` ${series.datapointUnit}` +
(series.datapointUnit ? ` ${series.datapointUnit}` : '') +
`<div style="font-size: 11px">${this.datePipe.transform(
minValue[0]
)}</div>`;
Expand All @@ -199,7 +199,7 @@ export class EchartsOptionsService {
}
value =
seriesValue[1]?.toString() +
` ${series.datapointUnit}` +
(series.datapointUnit ? ` ${series.datapointUnit}` : '') +
`<div style="font-size: 11px">${this.datePipe.transform(
seriesValue[0]
)}</div>`;
Expand Down

0 comments on commit 6ea25b6

Please sign in to comment.