| 1 | import { |
| 2 | createMarkdownWithPromptFrontmatter, |
| 3 | createPromptMarkdown, |
| 4 | } from "./createMarkdownPrompt.js"; |
| 5 | |
| 6 | describe("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(`--- |
| 18 | name: Test Prompt |
| 19 | description: A test prompt |
| 20 | invokable: true |
| 21 | --- |
| 22 | |
| 23 | This 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 | |
| 36 | Simple prompt content`); |
| 37 | }); |
| 38 | }); |
| 39 | |
| 40 | describe("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(`--- |
| 52 | name: Test Prompt |
| 53 | description: A test prompt |
| 54 | invokable: true |
| 55 | --- |
| 56 | |
| 57 | This 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(`--- |
| 64 | name: Simple Prompt |
| 65 | --- |
| 66 | |
| 67 | Simple 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(`--- |
| 76 | name: Prompt with Description |
| 77 | description: Test description |
| 78 | --- |
| 79 | |
| 80 | Content`); |
| 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(`--- |
| 89 | name: Trim Test |
| 90 | description: Trimmed Description |
| 91 | --- |
| 92 | |
| 93 | Content`); |
| 94 | }); |
| 95 | |
| 96 | test("should handle invokable false", () => { |
| 97 | const result = createPromptMarkdown("Invokable False", "Content", { |
| 98 | invokable: false, |
| 99 | }); |
| 100 | |
| 101 | expect(result).toBe(`--- |
| 102 | name: Invokable False |
| 103 | invokable: false |
| 104 | --- |
| 105 | |
| 106 | Content`); |
| 107 | }); |
| 108 | }); |