tests / executor.test.ts
import { describe, it, expect } from "vitest";
import { formatBytes } from "../src/executor_impl";
describe("formatBytes", () => {
it("should format 0 bytes", () => {
expect(formatBytes(0)).toBe("0 B");
});
it("should format negative as 0 B", () => {
expect(formatBytes(-1)).toBe("0 B");
expect(formatBytes(-100)).toBe("0 B");
});
it("should format positive bytes", () => {
expect(formatBytes(512)).toBe("512.00 B");
});
it("should format KB", () => {
expect(formatBytes(1024)).toBe("1.00 KB");
});
it("should format MB", () => {
expect(formatBytes(1024 * 1024)).toBe("1.00 MB");
});
it("should format GB", () => {
expect(formatBytes(1024 * 1024 * 1024)).toBe("1.00 GB");
});
it("should format TB", () => {
expect(formatBytes(1024 * 1024 * 1024 * 1024)).toBe("1.00 TB");
});
it("should format fractional KB", () => {
expect(formatBytes(1536)).toBe("1.50 KB");
});
it("should format large numbers", () => {
const result = formatBytes(5 * 1024 * 1024 * 1024);
expect(result).toBe("5.00 GB");
});
it("should format 1 byte", () => {
expect(formatBytes(1)).toBe("1.00 B");
});
it("should format 1023 bytes", () => {
expect(formatBytes(1023)).toBe("1023.00 B");
});
});
tests / executor.test.ts
import { describe, it, expect } from "vitest";
import { formatBytes } from "../src/executor_impl";
describe("formatBytes", () => {
it("should format 0 bytes", () => {
expect(formatBytes(0)).toBe("0 B");
});
it("should format negative as 0 B", () => {
expect(formatBytes(-1)).toBe("0 B");
expect(formatBytes(-100)).toBe("0 B");
});
it("should format positive bytes", () => {
expect(formatBytes(512)).toBe("512.00 B");
});
it("should format KB", () => {
expect(formatBytes(1024)).toBe("1.00 KB");
});
it("should format MB", () => {
expect(formatBytes(1024 * 1024)).toBe("1.00 MB");
});
it("should format GB", () => {
expect(formatBytes(1024 * 1024 * 1024)).toBe("1.00 GB");
});
it("should format TB", () => {
expect(formatBytes(1024 * 1024 * 1024 * 1024)).toBe("1.00 TB");
});
it("should format fractional KB", () => {
expect(formatBytes(1536)).toBe("1.50 KB");
});
it("should format large numbers", () => {
const result = formatBytes(5 * 1024 * 1024 * 1024);
expect(result).toBe("5.00 GB");
});
it("should format 1 byte", () => {
expect(formatBytes(1)).toBe("1.00 B");
});
it("should format 1023 bytes", () => {
expect(formatBytes(1023)).toBe("1023.00 B");
});
});