generated from nhcarrigan/template
feat: v1 prototype — core game systems #30
@@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user