diff --git a/apps/web/src/utils/format.ts b/apps/web/src/utils/format.ts index f4bfa60..2cf5e09 100644 --- a/apps/web/src/utils/format.ts +++ b/apps/web/src/utils/format.ts @@ -73,7 +73,9 @@ const formatSuffix = (value: number): string => { return `${(value / threshold).toFixed(2)}${suffix}`; } } - return value.toFixed(1); + return value < 1 + ? value.toFixed(2) + : value.toFixed(1); }; /** diff --git a/apps/web/test/format.spec.ts b/apps/web/test/format.spec.ts index 73c78fe..6e1a51d 100644 --- a/apps/web/test/format.spec.ts +++ b/apps/web/test/format.spec.ts @@ -28,8 +28,12 @@ describe("formatNumber", () => { expect(formatNumber(-1000)).toBe("-1.00K"); }); - it("should format zero as '0.0'", () => { - expect(formatNumber(0)).toBe("0.0"); + it("should format zero as '0.00'", () => { + expect(formatNumber(0)).toBe("0.00"); + }); + + it("should format small decimal values with two decimal places", () => { + expect(formatNumber(0.01)).toBe("0.01"); }); });