27 lines · 983 B · TypeScript
RawDownload
import { describe, expect, it } from "vitest"; import { splitPromptIntoComposerSegments } from "./composer-editor-mentions"; describe("splitPromptIntoComposerSegments", () => {  it("splits mention tokens followed by whitespace into mention segments", () => {    expect(splitPromptIntoComposerSegments("Inspect @AGENTS.md please")).toEqual([      { type: "text", text: "Inspect " },      { type: "mention", path: "AGENTS.md" },      { type: "text", text: " please" },    ]);  });   it("does not convert an incomplete trailing mention token", () => {    expect(splitPromptIntoComposerSegments("Inspect @AGENTS.md")).toEqual([      { type: "text", text: "Inspect @AGENTS.md" },    ]);  });   it("keeps newlines around mention tokens", () => {    expect(splitPromptIntoComposerSegments("one\n@src/index.ts \ntwo")).toEqual([      { type: "text", text: "one\n" },      { type: "mention", path: "src/index.ts" },      { type: "text", text: " \ntwo" },    ]);  });});