generated from nhcarrigan/template
feat: another balance and bug fix pass (#238)
Working through open issues — fixes, balance changes, and features. ## Closed - Closes #161 - Closes #181 - Closes #191 - Closes #199 - Closes #201 - Closes #202 - Closes #203 - Closes #204 - Closes #205 - Closes #206 - Closes #208 - Closes #211 - Closes #212 - Closes #213 - Closes #214 - Closes #216 - Closes #219 - Closes #220 - Closes #221 - Closes #222 - Closes #224 - Closes #225 - Closes #226 - Closes #228 - Closes #229 - Closes #230 - Closes #231 - Closes #232 - Closes #233 - Closes #234 - Closes #235 - Closes #236 ✨ This PR was created with help from Hikari~ 🌸 Reviewed-on: #238 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
This commit was merged in pull request #238.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatNumber } from "../src/utils/format.js";
|
||||
import { formatInteger, formatNumber } from "../src/utils/format.js";
|
||||
|
||||
describe("formatNumber", () => {
|
||||
describe("edge cases", () => {
|
||||
@@ -142,3 +142,59 @@ describe("formatNumber", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatInteger", () => {
|
||||
describe("edge cases", () => {
|
||||
it("should return '0' for NaN", () => {
|
||||
expect(formatInteger(Number.NaN)).toBe("0");
|
||||
});
|
||||
|
||||
it("should return '0' for Infinity", () => {
|
||||
expect(formatInteger(Infinity)).toBe("0");
|
||||
});
|
||||
|
||||
it("should format negative integers with a leading minus sign", () => {
|
||||
expect(formatInteger(-1500)).toBe("-1K");
|
||||
});
|
||||
|
||||
it("should format zero as '0'", () => {
|
||||
expect(formatInteger(0)).toBe("0");
|
||||
});
|
||||
|
||||
it("should format small integers without decimals", () => {
|
||||
expect(formatInteger(42)).toBe("42");
|
||||
});
|
||||
});
|
||||
|
||||
describe("named suffixes", () => {
|
||||
it("should format thousands with K suffix and no decimals", () => {
|
||||
expect(formatInteger(1500)).toBe("1K");
|
||||
});
|
||||
|
||||
it("should format millions with M suffix and no decimals", () => {
|
||||
expect(formatInteger(2_500_000)).toBe("2M");
|
||||
});
|
||||
|
||||
it("should format billions with B suffix", () => {
|
||||
expect(formatInteger(3_000_000_000)).toBe("3B");
|
||||
});
|
||||
|
||||
it("should format trillions with T suffix", () => {
|
||||
expect(formatInteger(1e12)).toBe("1T");
|
||||
});
|
||||
|
||||
it("should format quintillions with Qi suffix", () => {
|
||||
expect(formatInteger(1e18)).toBe("1Qi");
|
||||
});
|
||||
});
|
||||
|
||||
describe("letter suffixes", () => {
|
||||
it("should format values >= 1e36 with letter suffix 'a'", () => {
|
||||
expect(formatInteger(1e36)).toBe("1a");
|
||||
});
|
||||
|
||||
it("should format values >= 1e39 with letter suffix 'b'", () => {
|
||||
expect(formatInteger(1e39)).toBe("1b");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user