// The Lucia project. // Copyright 2026-2026 DSP, inc. All rights reserved. // Authors: // imacat.yang@dsp.im (imacat), 2026/03/05 import { describe, it, expect } from "vitest"; import shortScaleNumber from "@/module/shortScaleNumber.js"; describe("shortScaleNumber", () => { it("returns small numbers without abbreviation", () => { expect(shortScaleNumber(1).trim()).toBe("1"); expect(shortScaleNumber(999).trim()).toBe("999"); }); it("abbreviates thousands as k", () => { expect(shortScaleNumber(1000).trim()).toBe("1k"); expect(shortScaleNumber(1500).trim()).toBe("1.5k"); }); it("abbreviates millions as m", () => { expect(shortScaleNumber(1000000).trim()).toBe("1m"); }); it("abbreviates billions as b", () => { expect(shortScaleNumber(1000000000).trim()).toBe("1b"); }); it("abbreviates trillions as t", () => { expect(shortScaleNumber(1000000000000).trim()).toBe("1t"); }); it("rounds up using Math.ceil", () => { // 1234 -> 1.234k -> ceil(12.34)/10 = 1.3k expect(shortScaleNumber(1234).trim()).toBe("1.3k"); }); it("handles zero", () => { expect(shortScaleNumber(0).trim()).toBe("0"); }); });