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

ComposerStashMenu.test.ts

32 lines1.1 KB

1import {
2 formatComposerContextReference,
3 toComposerContextId,
4} from "@t3tools/shared/composerContextReferences";
5import { describe, expect, it } from "vite-plus/test";
6​
7import { stashEntrySnippet } from "./ComposerStashMenu";
8​
9const entry = (prompt: string) => ({
10 id: "stash-1",
11 createdAt: "2026-10-01T00:00:00.000Z",
12 prompt,
13 attachments: [],
14 droppedImageNames: [],
15});
16​
17describe("stashEntrySnippet", () => {
18 it("cuts a long prompt on a whole character with no space before the ellipsis", () => {
19 expect(stashEntrySnippet(entry(`${"a".repeat(89)}😀 and more`))).toBe(`${"a".repeat(89)}…`);
20 expect(stashEntrySnippet(entry(`${"a".repeat(88)}😀 and more`))).toBe(`${"a".repeat(88)}😀…`);
21 expect(stashEntrySnippet(entry(`${"a".repeat(89)} word`))).toBe(`${"a".repeat(89)}…`);
22 });
23​
24 it("shows context chips by their label", () => {
25 const file = formatComposerContextReference({
26 kind: "file",
27 contextId: toComposerContextId("readme"),
28 label: "README.md",
29 });
30 expect(stashEntrySnippet(entry(`Summarize ${file} please`))).toBe("Summarize README.md please");
31 });
32});