fix(map): convert actual demand display units
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { FLOW_DISPLAY_UNIT, isLpsFlowProperty, toM3h } from "./units";
|
||||
|
||||
describe("flow display units", () => {
|
||||
it("uses cubic meters per hour as the flow display unit", () => {
|
||||
expect(FLOW_DISPLAY_UNIT).toBe("m³/h");
|
||||
});
|
||||
|
||||
it("converts L/s values to m³/h", () => {
|
||||
expect(toM3h(10, "lps")).toBe(36);
|
||||
expect(toM3h(10, "L/s")).toBe(36);
|
||||
});
|
||||
|
||||
it("recognizes computed properties that arrive from the backend in L/s", () => {
|
||||
expect(isLpsFlowProperty("flow")).toBe(true);
|
||||
expect(isLpsFlowProperty("actual_demand")).toBe(true);
|
||||
expect(isLpsFlowProperty("actualdemand")).toBe(true);
|
||||
expect(isLpsFlowProperty("pressure")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,9 @@
|
||||
export const FLOW_DISPLAY_UNIT = "m³/h";
|
||||
const M3H_FACTOR = 3600;
|
||||
const LPS_FLOW_PROPERTIES = new Set(["flow", "actual_demand", "actualdemand"]);
|
||||
|
||||
export const isLpsFlowProperty = (property: string) =>
|
||||
LPS_FLOW_PROPERTIES.has(property);
|
||||
|
||||
export const toM3h = (value: number, sourceUnit: string = "m³/s") => {
|
||||
if (!Number.isFinite(value)) return Number.NaN;
|
||||
|
||||
Reference in New Issue
Block a user