26 lines
860 B
TypeScript
26 lines
860 B
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { formatNumber, formatQtyDual } from "./utils";
|
|
|
|
describe("formatQtyDual", () => {
|
|
it("shows both figures when a conversion happened", () => {
|
|
expect(formatQtyDual(29.96, "ton", 29960, "kg")).toBe(
|
|
`${formatNumber(29.96)} ton · ${formatNumber(29960)} kg`,
|
|
);
|
|
});
|
|
|
|
it("shows one figure when the units match", () => {
|
|
expect(formatQtyDual(5, "ton", 5, "ton")).toBe("5 ton");
|
|
});
|
|
|
|
it("shows one figure when the slip recorded no unit", () => {
|
|
expect(formatQtyDual(5, "ton", 5, "")).toBe("5 ton");
|
|
});
|
|
|
|
it("omits the unit entirely when the PO line has none", () => {
|
|
expect(formatQtyDual(5, "", 5, "")).toBe("5");
|
|
});
|
|
|
|
it("falls back to the raw figure when nothing converted", () => {
|
|
expect(formatQtyDual(0, "ton", 12, "m3")).toBe("0 ton · 12 m3");
|
|
});
|
|
});
|