import { createCurrencyFormatter, formatCurrencyRounding } from "../../src/ts/mmviz-data/format"; test("Test createCurrencyFormatter", () => { const currencyFormatter = createCurrencyFormatter("$,.2s"); expect(currencyFormatter(16119719758.53)).toBe("$16B"); expect(currencyFormatter(9719758.53)).toBe("$9.7M"); expect(currencyFormatter(19758.53)).toBe("$20k"); expect(currencyFormatter(758.53)).toBe("$760"); expect(currencyFormatter(0.53)).toBe("$0.53"); }); test("Test formatCurrencyRounding", () => { expect(formatCurrencyRounding(9719758.53)).toBe("$9,719,759"); expect(formatCurrencyRounding(9719758.53, {maximumFractionDigits: 2})).toBe("$9,719,758.53"); expect(formatCurrencyRounding(9719758.53, {maximumFractionDigits: 2}, 1000000)).toBe("$9.72"); }); test("Test createCurrencyFormatter Error", () => { expect(() => { createCurrencyFormatter("abc"); }).toThrow(Error); });