Skip to content

Commit

Permalink
test: add test to getshowcase & getmetricvalue functions
Browse files Browse the repository at this point in the history
  • Loading branch information
flesa committed Nov 19, 2020
1 parent c320ba2 commit 2751d45
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { LoadingState, PanelData, dateTime } from "@grafana/data";

import { createMinimalSeries, createSeries } from "./__mocks__/create-series";

import { getMetricValueByName } from "./index";
import {
getMetricValue,
getMetricValueByName,
getShowcaseMetricValue,
} from "./index";

declare global {
interface Window {
Expand Down Expand Up @@ -44,3 +48,25 @@ describe("getMetricValueByName", () => {
);
});
});

describe("getMetricValue", () => {
it("retrieves correct value", () => {
expect(getMetricValue("test", true)).toBeGreaterThanOrEqual(0);
expect(getMetricValue("test", true)).toBeLessThanOrEqual(1000);
expect(getMetricValue("test", true, [0, 10], 2)).toBeGreaterThanOrEqual(0);
expect(getMetricValue("test", true, [0, 10], 2)).toBeLessThanOrEqual(10);
});
});

describe("getShowcaseMetricValue", () => {
it("retrieves correct value", () => {
expect(getShowcaseMetricValue()).toBeGreaterThanOrEqual(0);
expect(getShowcaseMetricValue()).toBeLessThanOrEqual(1000);
expect(
getShowcaseMetricValue({ range: [0, 10], decimals: 2 })
).toBeGreaterThanOrEqual(0);
expect(
getShowcaseMetricValue({ range: [0, 10], decimals: 2 })
).toBeLessThanOrEqual(10);
});
});

0 comments on commit 2751d45

Please sign in to comment.