diff --git a/package.json b/package.json index 3769e8957..a257d829a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@netdata/charts", - "version": "6.12.11", + "version": "6.12.12", "description": "Netdata frontend SDK and chart utilities", "main": "dist/index.js", "module": "dist/es6/index.js", diff --git a/src/components/hocs/withTile.js b/src/components/hocs/withTile.js index 22ab6641b..2cf8948f7 100644 --- a/src/components/hocs/withTile.js +++ b/src/components/hocs/withTile.js @@ -43,7 +43,7 @@ export const Title = () => { const chart = useChart() const title = useTitle() const units = useUnitSign({ withoutConversion: true, long: true }) - const hideUnits = useAttributeValue("hideUnits") + const hideUnits = useAttributeValue("hideUnits") ?? true const isMinimal = useIsMinimal() const onClick = event => { diff --git a/src/components/hocs/withTile.test.js b/src/components/hocs/withTile.test.js index 7144bca91..6e18081b4 100644 --- a/src/components/hocs/withTile.test.js +++ b/src/components/hocs/withTile.test.js @@ -4,21 +4,41 @@ import "@testing-library/jest-dom" import { makeHeatmapPayload, renderWithChart } from "@jest/testUtilities" import { Title } from "./withTile" +const renderTitle = async hideUnits => { + const { chart } = renderWithChart(
) + const payload = makeHeatmapPayload(["storage"], [[1024]]) + payload.view.title = "Storage change" + payload.view.chart_type = "number" + payload.view.units = "KiB" + payload.view.dimensions.units = ["KiB"] + + chart.doneFetch(payload) + await new Promise(resolve => setTimeout(resolve, 0)) + + if (hideUnits !== undefined) chart.updateAttribute("hideUnits", hideUnits) + + renderWithChart(