Files
cobble/src/utils/message-preview.test.ts
T
tbenandClaude Opus 5.5 1208eac6b7 Replace the composer textarea with a Tiptap markdown editor
The composer now writes markdown with bold, italic, strike, code,
links, quotes and lists, from shortcuts, markdown typing or a bubble
over the selection. @ mentions a bot and # a workspace, shown as chips
and saved as [bot:ID] / [workspace:ID]. Text selected in a message can
be quoted into the composer. User messages render as markdown, and
replies tell the bot who and what the user mentioned.

Adds an ESM stand-in for use-sync-external-store, since bunext keeps
React external in page bundles and the CommonJS original requires it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 05:48:23 +01:00

26 lines
1.1 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import messagePreview from "./message-preview";
describe("messagePreview", () => {
test("strips markdown and names computers plainly", () => {
expect(
messagePreview({
text: "## Found it\n\nYour **GitHub** session is on [computer:3]. See [the docs](https://x.y) and `search_computers`.\n\n- *one*\n- two",
}),
).toBe("Found it Your GitHub session is on a computer. See the docs and search_computers. one two");
});
test("names bots plainly", () => {
expect(messagePreview({ text: "[bot:4] is on it." })).toBe("a bot is on it.");
expect(messagePreview({ text: "Moved to [workspace:2]." })).toBe("Moved to a workspace.");
});
test("keeps code text without its fences", () => {
expect(messagePreview({ text: "Run:\n```bash\nls ~\n```" })).toBe("Run: ls ~");
});
test("leaves plain text alone", () => {
expect(messagePreview({ text: "All done, 3 files_moved." })).toBe("All done, 3 files_moved.");
});
});