Skip to content

Commit 4c79ac2

Browse files
authored
test: add missing coverage for formatLocation and formatSize (#20534)
1 parent 4f5c0a8 commit 4c79ac2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

test/SizeFormatHelpers.unittest.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ describe("SizeFormatHelpers", () => {
88
expect(formatSize(0)).toBe("0 bytes");
99
});
1010

11+
it("should handle negative size", () => {
12+
expect(formatSize(-1)).toBe("0 bytes");
13+
});
14+
1115
it("should handle bytes", () => {
1216
expect(formatSize(1000)).toBe("1000 bytes");
1317
});

test/formatLocation.unittest.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ describe("formatLocation", () => {
7171
end: /f/
7272
},
7373
result: ""
74+
},
75+
{
76+
name: "name with index",
77+
loc: { name: "foo", index: 3 },
78+
result: "foo[3]"
79+
},
80+
{
81+
name: "name only",
82+
loc: { name: "bar" },
83+
result: "bar"
7484
}
7585
];
7686
for (const testCase of testCases) {

0 commit comments

Comments
 (0)