24 lines
934 B
TypeScript
24 lines
934 B
TypeScript
import { BufferDrawing, CharBuffer } from "./base.ts";
|
|
import { describe, expect, it } from "./testing.ts";
|
|
|
|
describe(CharBuffer, () => {
|
|
it("initializes empty, sets and gets characters", () => {
|
|
const buffer = new CharBuffer({ w: 3, h: 2 });
|
|
expect(buffer.toString()).toEqual(" ");
|
|
buffer.set({ x: 2, y: 0 }, { ch: "x", fg: 1, bg: 4 });
|
|
buffer.set({ x: 1, y: 1 }, { ch: "y", fg: 2, bg: 5 });
|
|
expect(buffer.toString()).toEqual(" x y ");
|
|
expect(buffer.get({ x: 0, y: 0 })).toEqual({ ch: " ", fg: 0, bg: 0 });
|
|
expect(buffer.get({ x: 1, y: 1 })).toEqual({ ch: "y", fg: 2, bg: 5 });
|
|
});
|
|
});
|
|
|
|
describe(BufferDrawing, () => {
|
|
it("draws text", () => {
|
|
const buffer = new CharBuffer({ w: 4, h: 2 });
|
|
const drawing = new BufferDrawing(buffer, []);
|
|
drawing.text("testing", { x: -1, y: 0 });
|
|
drawing.text("so", { x: 1, y: 1 });
|
|
expect(buffer.toString()).toEqual("esti so ");
|
|
});
|
|
});
|