formats.exposed/test/common/formatBytes.test.ts

18 lines
512 B
TypeScript
Raw Normal View History

import { assertEquals } from "assert";
import { b } from "../helpers.ts";
import formatBytes from "../../public/common/formatBytes.js";
Deno.test("returns the empty string for no bytes", () => {
assertEquals(formatBytes(b()), "");
});
Deno.test("formats one byte", () => {
assertEquals(formatBytes(b(0)), "00");
assertEquals(formatBytes(b(10)), "0a");
assertEquals(formatBytes(b(255)), "ff");
});
Deno.test("formats multiple bytes", () => {
assertEquals(formatBytes(b(0, 10, 255)), "00 0a ff");
});