The browsable Downloaded library + Transfers split + on-disk usage
(f25deba, plus today's grouping/perf fixes) fully implement UR-055 and
UR-056, but the requirements doc still listed them and DR-081..085 as
Planned. Flip to Done.
Also fix UT-id collisions: the downloaded-browse and formatBytes tests
reused UT-046..050 (already assigned to smart-cache/playlist tests in the
matrix). Reassign to UT-071..078 and register them in §4, including the
new music/TV container-rollup and orphan-leaf regression tests.
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { formatBytes } from "./formatBytes";
|
|
|
|
// TRACES: UR-056 | DR-085 | UT-071
|
|
describe("formatBytes", () => {
|
|
it("renders zero and non-positive as '0 B'", () => {
|
|
expect(formatBytes(0)).toBe("0 B");
|
|
expect(formatBytes(-1)).toBe("0 B");
|
|
expect(formatBytes(NaN)).toBe("0 B");
|
|
expect(formatBytes(Infinity)).toBe("0 B");
|
|
});
|
|
|
|
it("renders whole bytes below 1 KB", () => {
|
|
expect(formatBytes(1)).toBe("1 B");
|
|
expect(formatBytes(999)).toBe("999 B");
|
|
});
|
|
|
|
it("crosses to KB at 1000 bytes (decimal units)", () => {
|
|
expect(formatBytes(1000)).toBe("1 KB");
|
|
expect(formatBytes(1500)).toBe("1.5 KB");
|
|
});
|
|
|
|
it("shows 2-3 significant figures", () => {
|
|
expect(formatBytes(340_000_000)).toBe("340 MB");
|
|
expect(formatBytes(1_200_000_000)).toBe("1.2 GB");
|
|
expect(formatBytes(48_000_000)).toBe("48 MB");
|
|
});
|
|
|
|
it("trims trailing zeros", () => {
|
|
expect(formatBytes(2_000_000_000)).toBe("2 GB");
|
|
expect(formatBytes(10_000_000)).toBe("10 MB");
|
|
});
|
|
|
|
it("scales into large units", () => {
|
|
expect(formatBytes(3_400_000_000)).toBe("3.4 GB");
|
|
expect(formatBytes(1_000_000_000_000)).toBe("1 TB");
|
|
});
|
|
|
|
it("uses no decimals at or above 100 of a unit", () => {
|
|
// 123.4 MB → "123 MB" (2-3 sig figs, whole number band)
|
|
expect(formatBytes(123_400_000)).toBe("123 MB");
|
|
});
|
|
});
|