Files
Netcatty/components/terminal/runtime/telnetLocalEcho.test.ts
T
陈大猫 0d8d68d954 fix(telnet): handle NVT newlines and echo mode (#1649)
* fix(telnet): normalize NVT newlines

* fix(telnet): handle echo negotiation

* fix(telnet): align echo negotiation
2026-06-25 14:47:17 +08:00

22 lines
807 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { formatTelnetLocalEcho } from "./telnetLocalEcho";
test("formatTelnetLocalEcho echoes printable input and newlines", () => {
assert.equal(formatTelnetLocalEcho("ps\r"), "ps\r\n");
assert.equal(formatTelnetLocalEcho("one\ntwo"), "one\r\ntwo");
});
test("formatTelnetLocalEcho renders local editing control keys", () => {
assert.equal(formatTelnetLocalEcho("\x7f"), "\b \b");
assert.equal(formatTelnetLocalEcho("\b"), "\b \b");
assert.equal(formatTelnetLocalEcho("\x03"), "^C");
});
test("formatTelnetLocalEcho ignores non-display escape input", () => {
assert.equal(formatTelnetLocalEcho("\x1b[A"), "");
assert.equal(formatTelnetLocalEcho("\x1bOP"), "");
assert.equal(formatTelnetLocalEcho("\x1bb"), "");
});