18 lines
512 B
TypeScript
18 lines
512 B
TypeScript
|
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");
|
||
|
});
|