Files
llmx/codex-cli/tests/multiline-ctrl-enter-submit.test.tsx
Ilan Bigio 59a180ddec Initial commit
Signed-off-by: Ilan Bigio <ilan@openai.com>
2025-04-16 12:56:08 -04:00

42 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Ctrl+Enter (CSIu 13;5u) should submit the buffer.
import { renderTui } from "./ui-test-helpers.js";
import MultilineTextEditor from "../src/components/chat/multiline-editor.js";
import * as React from "react";
import { describe, it, expect, vi } from "vitest";
async function type(
stdin: NodeJS.WritableStream,
text: string,
flush: () => Promise<void>,
) {
stdin.write(text);
await flush();
}
describe("MultilineTextEditor Ctrl+Enter submits", () => {
it("calls onSubmit when CSI 13;5u is received", async () => {
const onSubmit = vi.fn();
const { stdin, flush, cleanup } = renderTui(
React.createElement(MultilineTextEditor, {
height: 5,
width: 20,
onSubmit,
}),
);
await flush();
await type(stdin, "hello", flush);
await type(stdin, "\u001B[13;5u", flush); // Ctrl+Enter (modifier 5 = Ctrl)
await flush();
expect(onSubmit).toHaveBeenCalledTimes(1);
expect(onSubmit.mock.calls[0]![0]).toBe("hello");
cleanup();
});
});