21 lines
869 B
TypeScript
21 lines
869 B
TypeScript
|
|
import { describe, expect, it } from "vitest";
|
||
|
|
|
||
|
|
import { isSgrWheelReport } from "./dashboard-terminal-input";
|
||
|
|
|
||
|
|
describe("isSgrWheelReport", () => {
|
||
|
|
it("accepts xterm SGR wheel reports, including modifiers", () => {
|
||
|
|
expect(isSgrWheelReport("\x1b[<64;80;25M")).toBe(true);
|
||
|
|
expect(isSgrWheelReport("\x1b[<65;80;25M")).toBe(true);
|
||
|
|
expect(isSgrWheelReport("\x1b[<84;80;25M")).toBe(true);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("rejects clicks, releases, malformed reports, and arbitrary input", () => {
|
||
|
|
expect(isSgrWheelReport("\x1b[<0;80;25M")).toBe(false);
|
||
|
|
expect(isSgrWheelReport("\x1b[<64;80;25m")).toBe(false);
|
||
|
|
expect(isSgrWheelReport("\x1b[<66;80;25M")).toBe(false);
|
||
|
|
expect(isSgrWheelReport("\x1b[<64;10000;25M")).toBe(false);
|
||
|
|
expect(isSgrWheelReport("\x1b[<64;80;25M\rmalicious")).toBe(false);
|
||
|
|
expect(isSgrWheelReport("/submit\r")).toBe(false);
|
||
|
|
});
|
||
|
|
});
|