master @ 30 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ import { describe, expect, it } from "vitest"; │
│ import { buildBigNumber, BIG_ROWS } from "./BigNumber"; │
│ import { len } from "../../lib/ascii"; │
│ │
│ describe("buildBigNumber", () => { │
│ it("renders five rows of block glyphs", () => { │
│ const rows = buildBigNumber(42, 86).split("\n"); │
│ expect(rows).toHaveLength(BIG_ROWS); │
│ expect(rows.join("")).toMatch(/█/); │
│ }); │
│ │
│ it("keeps digits four cells apart", () => { │
│ // "10" ? 3 + 1 gap + 3 = 7 cells on the widest row │
│ const rows = buildBigNumber(10, 86).split("\n"); │
│ expect(Math.max(...rows.map(len))).toBe(7); │
│ }); │
│ │
│ it("supports separators", () => { │
│ expect(() => buildBigNumber("1,024.5", 86)).not.toThrow(); │
│ }); │
│ │
│ it("throws on characters without glyphs", () => { │
│ expect(() => buildBigNumber("42%", 86)).toThrow(/no glyph/); │
│ }); │
│ │
│ it("fails the grid when the figure overflows the frame", () => { │
│ expect(() => buildBigNumber("888888888888888", 48)).toThrow(/cells/); │
│ }); │
│ }); │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ import { describe, expect, it } from "vitest │
│ "; │
│ import { buildBigNumber, BIG_ROWS } from "./ │
│ BigNumber"; │
│ import { len } from "../../lib/ascii"; │
│ │
│ describe("buildBigNumber", () => { │
│ it("renders five rows of block glyphs", () │
│ => { │
│ const rows = buildBigNumber(42, 86).spli │
│ t("\n"); │
│ expect(rows).toHaveLength(BIG_ROWS); │
│ expect(rows.join("")).toMatch(/█/); │
│ }); │
│ │
│ it("keeps digits four cells apart", () => │
│ { │
│ // "10" ? 3 + 1 gap + 3 = 7 cells on the │
│ widest row │
│ const rows = buildBigNumber(10, 86).spli │
│ t("\n"); │
│ expect(Math.max(...rows.map(len))).toBe( │
│ 7); │
│ }); │
│ │
│ it("supports separators", () => { │
│ expect(() => buildBigNumber("1,024.5", 8 │
│ 6)).not.toThrow(); │
│ }); │
│ │
│ it("throws on characters without glyphs", │
│ () => { │
│ expect(() => buildBigNumber("42%", 86)). │
│ toThrow(/no glyph/); │
│ }); │
│ │
│ it("fails the grid when the figure overflo │
│ ws the frame", () => { │
│ expect(() => buildBigNumber("88888888888 │
│ 8888", 48)).toThrow(/cells/); │
│ }); │
│ }); │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET