feat(lib): shelf sort/section pure helpers + formatSize extraction, table tests

This commit is contained in:
2026-09-08 17:29:07 +08:00
parent 03bc537308
commit 913f3286bb
5 changed files with 72 additions and 9 deletions
+18
View File
@@ -0,0 +1,18 @@
import { describe, expect, it } from "vitest";
import { formatSize } from "../src/lib/format";
describe("formatSize", () => {
it("renders human sizes across units", () => {
expect(formatSize(0)).toBe("");
expect(formatSize(512)).toBe("512 B");
expect(formatSize(2048)).toBe("2.0 KB");
expect(formatSize(15 * 1024 * 1024)).toBe("15 MB");
expect(formatSize(3.2 * 1024 ** 3)).toBe("3.2 GB");
});
it("returns empty for non-positive and keeps one decimal below 10", () => {
expect(formatSize(-1)).toBe("");
expect(formatSize(1024)).toBe("1.0 KB");
expect(formatSize(10 * 1024)).toBe("10 KB");
});
});