Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

useComposerMultilinePrompt.browser.test.tsx

23 lines947 Bytes

1import { expect, it } from "vite-plus/test";
2​
3import { render } from "../../../test/render";
4import { useComposerMultilinePrompt } from "./useComposerMultilinePrompt";
5​
6function Composer({ text }: { readonly text: string }) {
7 const [multiline, observeBody] = useComposerMultilinePrompt();
8 return (
9 <div ref={observeBody} style={{ width: 200, lineHeight: "20px" }}>
10 <div data-testid="composer-editor" contentEditable suppressContentEditableWarning>
11 {text}
12 </div>
13 <output>{multiline ? "multiline" : "single line"}</output>
14 </div>
15 );
17​
18it("notices when typing makes the prompt wrap", async () => {
19 await using screen = await render(<Composer text="short" />, { router: false });
20 await expect.element(screen.getByText("single line")).toBeVisible();
21 await screen.rerender(<Composer text={"a long prompt that wraps ".repeat(6)} />);
22 await expect.element(screen.getByText("multiline")).toBeVisible();
23});