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

composer-editor-mentions.test.ts

41 lines1.5 KB

1import { describe, expect, it } from "vitest";
2​
3import { splitPromptIntoComposerSegments } from "./composer-editor-mentions";
4import { INLINE_TERMINAL_CONTEXT_PLACEHOLDER } from "./lib/terminalContext";
5​
6describe("splitPromptIntoComposerSegments", () => {
7 it("splits mention tokens followed by whitespace into mention segments", () => {
8 expect(splitPromptIntoComposerSegments("Inspect @AGENTS.md please")).toEqual([
9 { type: "text", text: "Inspect " },
10 { type: "mention", path: "AGENTS.md" },
11 { type: "text", text: " please" },
12 ]);
13 });
14​
15 it("does not convert an incomplete trailing mention token", () => {
16 expect(splitPromptIntoComposerSegments("Inspect @AGENTS.md")).toEqual([
17 { type: "text", text: "Inspect @AGENTS.md" },
18 ]);
19 });
20​
21 it("keeps newlines around mention tokens", () => {
22 expect(splitPromptIntoComposerSegments("one\n@src/index.ts \ntwo")).toEqual([
23 { type: "text", text: "one\n" },
24 { type: "mention", path: "src/index.ts" },
25 { type: "text", text: " \ntwo" },
26 ]);
27 });
28​
29 it("keeps inline terminal context placeholders at their prompt positions", () => {
30 expect(
31 splitPromptIntoComposerSegments(
32 `Inspect ${INLINE_TERMINAL_CONTEXT_PLACEHOLDER}@AGENTS.md please`,
33 ),
34 ).toEqual([
35 { type: "text", text: "Inspect " },
36 { type: "terminal-context", context: null },
37 { type: "mention", path: "AGENTS.md" },
38 { type: "text", text: " please" },
39 ]);
40 });
41});