master @ 23 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ import { describe, expect, it } from "vitest"; │
│ import { buildToast, TOAST_W } from "./Toast"; │
│ import { len } from "../../lib/ascii"; │
│ │
│ describe("buildToast", () => { │
│ it("renders every line at the fixed toast width", () => { │
│ for (const line of buildToast("transmission queued").split("\n")) { │
│ expect(len(line)).toBe(TOAST_W); │
│ } │
│ }); │
│ │
│ it("prefixes the status tag and uppercases the message", () => { │
│ expect(buildToast("saved", "ok")).toContain("[ OK ] SAVED"); │
│ expect(buildToast("lost", "error")).toContain("[ !! ] LOST"); │
│ }); │
│ │
│ it("aligns wrapped continuation lines under the message", () => { │
│ const lines = buildToast("a message long enough to wrap onto more lines").spli │
│ t("\n"); │
│ expect(lines.length).toBeGreaterThan(3); │
│ expect(lines[2]).toMatch(/^│ \S/); │
│ }); │
│ }); │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ import { describe, expect, it } from "vitest │
│ "; │
│ import { buildToast, TOAST_W } from "./Toast │
│ "; │
│ import { len } from "../../lib/ascii"; │
│ │
│ describe("buildToast", () => { │
│ it("renders every line at the fixed toast │
│ width", () => { │
│ for (const line of buildToast("transmiss │
│ ion queued").split("\n")) { │
│ expect(len(line)).toBe(TOAST_W); │
│ } │
│ }); │
│ │
│ it("prefixes the status tag and uppercases │
│ the message", () => { │
│ expect(buildToast("saved", "ok")).toCont │
│ ain("[ OK ] SAVED"); │
│ expect(buildToast("lost", "error")).toCo │
│ ntain("[ !! ] LOST"); │
│ }); │
│ │
│ it("aligns wrapped continuation lines unde │
│ r the message", () => { │
│ const lines = buildToast("a message long │
│ enough to wrap onto more lines").split("\n" │
│ ); │
│ expect(lines.length).toBeGreaterThan(3); │
│ expect(lines[2]).toMatch(/^│ \S/) │
│ ; │
│ }); │
│ }); │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET