28 lines
1 KiB
TypeScript
28 lines
1 KiB
TypeScript
import { Display } from "./display.ts";
|
|
import { describe, expect, it } from "./deps.testing.ts";
|
|
|
|
describe(Display, () => {
|
|
it("buffers unique events", async () => {
|
|
const display = new Display();
|
|
await display.pushEvent({ key: "a" });
|
|
await display.pushEvent({ key: "b" });
|
|
await display.pushEvent({ key: "a" });
|
|
await display.pushEvent({ click: { x: 0, y: 0 } });
|
|
await display.pushEvent({ click: { x: 1, y: 0 } });
|
|
await display.pushEvent({ click: { x: 0, y: 0 } });
|
|
await display.pushEvent({ size: { w: 1, h: 1 } });
|
|
await display.pushEvent({ size: { w: 1, h: 2 } });
|
|
await display.pushEvent({ size: { w: 1, h: 1 } });
|
|
await display.pushEvent({ key: "b" });
|
|
await display.pushEvent({ click: { x: 1, y: 0 } });
|
|
await display.pushEvent({ size: { w: 1, h: 2 } });
|
|
expect(await display.getEvents()).toEqual([
|
|
{ key: "a" },
|
|
{ key: "b" },
|
|
{ click: { x: 0, y: 0 } },
|
|
{ click: { x: 1, y: 0 } },
|
|
{ size: { w: 1, h: 1 } },
|
|
{ size: { w: 1, h: 2 } },
|
|
]);
|
|
});
|
|
});
|