Something went wrong. Try again.
Large file storage for AT Protocol: an IPFS server & gateway with XRPC upload & admin. atfs.dev
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435import { describe, expect, it } from "vitest";
import { formatBytes, formatDate } from "./format.js";
describe("formatBytes", () => { it("keeps small sizes exact", () => { expect(formatBytes(0)).toBe("0 B"); expect(formatBytes(999)).toBe("999 B"); });
it("scales through decimal units", () => { expect(formatBytes(4123)).toBe("4.1 kB"); expect(formatBytes(3_000_000)).toBe("3.0 MB"); expect(formatBytes(285_000_000)).toBe("285 MB"); });
it("says nothing rather than NaN when the size is missing", () => { expect(formatBytes(undefined)).toBe("—"); });});
describe("formatDate", () => { it("renders a timestamp as a calendar date", () => { expect(formatDate("2026-08-21T09:14:02Z")).toMatch(/2026/); });
// An instance that took the upload before its clock was set reports no // firstSeen at all, and a stranger's instance can report anything. it("says nothing for an absent or unparseable time", () => { expect(formatDate(null)).toBe("—"); expect(formatDate(undefined)).toBe("—"); expect(formatDate("whenever")).toBe("—"); });});