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

composer-editor-mentions.test.ts

27 lines983 Bytes

1import { describe, expect, it } from "vitest";
2​
3import { splitPromptIntoComposerSegments } from "./composer-editor-mentions";
4​
5describe("splitPromptIntoComposerSegments", () => {
6 it("splits mention tokens followed by whitespace into mention segments", () => {
7 expect(splitPromptIntoComposerSegments("Inspect @AGENTS.md please")).toEqual([
8 { type: "text", text: "Inspect " },
9 { type: "mention", path: "AGENTS.md" },
10 { type: "text", text: " please" },
11 ]);
12 });
13​
14 it("does not convert an incomplete trailing mention token", () => {
15 expect(splitPromptIntoComposerSegments("Inspect @AGENTS.md")).toEqual([
16 { type: "text", text: "Inspect @AGENTS.md" },
17 ]);
18 });
19​
20 it("keeps newlines around mention tokens", () => {
21 expect(splitPromptIntoComposerSegments("one\n@src/index.ts \ntwo")).toEqual([
22 { type: "text", text: "one\n" },
23 { type: "mention", path: "src/index.ts" },
24 { type: "text", text: " \ntwo" },
25 ]);
26 });
27});