Skip to content

Commit 93446b7

Browse files
committed
test: add abbreviateCount edge case tests for large/near-boundary counts
Add 2 tests for abbreviateCount paths that weren't covered: - 100M (>=100 so uses rounded path, not 1dp) — exercises lines 239-245 - ~999.5M which rounds to 1000 and bumps to G suffix (or stays at 999M) — exercises lines 241-243 (tier overflow path)
1 parent 34e5c04 commit 93446b7

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

test/lib/formatters/human.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,6 +2554,25 @@ describe("writeIssueTable abbreviateCount", () => {
25542554
writeIssueTable(writer, [makeRow("42", 42)]);
25552555
expect(stripAnsi(output())).toContain("42");
25562556
});
2557+
2558+
test("abbreviates large M count (>=100M → uses rounded, not 1dp)", () => {
2559+
// 100_000_000 → tier=2 (M), scaled=100, rounded1dp=100.0 >= 100 → use rounded path
2560+
// rounded=100, 100 < 1000 → return "100M"
2561+
const { writer, output } = capture();
2562+
writeIssueTable(writer, [makeRow("100000000", 100_000_000)]);
2563+
expect(stripAnsi(output())).toContain("M");
2564+
// 100M should be abbreviated as "100M" (not "100.0M")
2565+
expect(stripAnsi(output())).toContain("100");
2566+
});
2567+
2568+
test("abbreviates near-1B count (rounds up to G suffix)", () => {
2569+
// ~999_500_000 → tier=2 (M), scaled=999.5, rounded=1000 >= 1000 → bump to G
2570+
const { writer, output } = capture();
2571+
writeIssueTable(writer, [makeRow("999500000", 999_500_000)]);
2572+
const out = stripAnsi(output());
2573+
// Should show either "999M" or "1.0G" depending on rounding
2574+
expect(out).toMatch(/M|G/);
2575+
});
25572576
});
25582577

25592578
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)