Files
llmx/codex-cli/tests/multiline-enter-submit-cr.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
958 B
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.
// Plain Enter (CR) should submit.
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 Enter submits (CR)", () => {
it("calls onSubmit when \r 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, "\r", flush);
await flush();
expect(onSubmit).toHaveBeenCalledTimes(1);
expect(onSubmit.mock.calls[0]![0]).toBe("hello");
cleanup();
});
});