Elffuss BraidHub

kikocis/continue public

main · 2.3 KiBRawPermalink
1import {
2 createMarkdownWithPromptFrontmatter,
3 createPromptMarkdown,
4} from "./createMarkdownPrompt.js";
5
6describe("createMarkdownWithPromptFrontmatter", () => {
7 test("should create properly formatted markdown with frontmatter", () => {
8 const frontmatter = {
9 name: "Test Prompt",
10 description: "A test prompt",
11 invokable: true,
12 };
13 const prompt = "This is the prompt content";
14
15 const result = createMarkdownWithPromptFrontmatter(frontmatter, prompt);
16
17 expect(result).toBe(`---
18name: Test Prompt
19description: A test prompt
20invokable: true
21---
22
23This is the prompt content`);
24 });
25
26 test("should handle empty frontmatter", () => {
27 const frontmatter = {};
28 const prompt = "Simple prompt content";
29
30 const result = createMarkdownWithPromptFrontmatter(frontmatter, prompt);
31
32 expect(result).toBe(`---
33{}
34---
35
36Simple prompt content`);
37 });
38});
39
40describe("createPromptMarkdown", () => {
41 test("should create properly formatted markdown with all options", () => {
42 const result = createPromptMarkdown(
43 "Test Prompt",
44 "This is the prompt content",
45 {
46 description: "A test prompt",
47 invokable: true,
48 },
49 );
50
51 expect(result).toBe(`---
52name: Test Prompt
53description: A test prompt
54invokable: true
55---
56
57This is the prompt content`);
58 });
59
60 test("should handle minimal configuration", () => {
61 const result = createPromptMarkdown("Simple Prompt", "Simple content");
62
63 expect(result).toBe(`---
64name: Simple Prompt
65---
66
67Simple content`);
68 });
69
70 test("should handle description only", () => {
71 const result = createPromptMarkdown("Prompt with Description", "Content", {
72 description: "Test description",
73 });
74
75 expect(result).toBe(`---
76name: Prompt with Description
77description: Test description
78---
79
80Content`);
81 });
82
83 test("should trim name and description", () => {
84 const result = createPromptMarkdown(" Trim Test ", "Content", {
85 description: " Trimmed Description ",
86 });
87
88 expect(result).toBe(`---
89name: Trim Test
90description: Trimmed Description
91---
92
93Content`);
94 });
95
96 test("should handle invokable false", () => {
97 const result = createPromptMarkdown("Invokable False", "Content", {
98 invokable: false,
99 });
100
101 expect(result).toBe(`---
102name: Invokable False
103invokable: false
104---
105
106Content`);
107 });
108});