Elffuss BraidHub

kikocis/continue public

d0cd3fef8227 · 1.3 KiBRawPermalink
1import { PromptTemplate } from "..";
2import { serializePromptTemplates } from "./util";
3
4describe("serializePromptTemplates", () => {
5 it("should return undefined for undefined input", () => {
6 expect(serializePromptTemplates(undefined)).toBeUndefined();
7 });
8
9 it("should convert function templates to empty strings", () => {
10 const functionTemplate: PromptTemplate = () => "Generated template";
11 const templates: Record<string, PromptTemplate> = {
12 template1: functionTemplate,
13 };
14
15 const result = serializePromptTemplates(templates);
16
17 expect(result).toEqual({ template1: "" });
18 });
19
20 it("should pass through string templates unchanged", () => {
21 const templates: Record<string, PromptTemplate> = {
22 template1: "This is a static template",
23 template2: "Another static template",
24 };
25
26 const result = serializePromptTemplates(templates);
27
28 expect(result).toEqual(templates);
29 });
30
31 it("should handle mixed template types", () => {
32 const functionTemplate: PromptTemplate = () => "Generated template";
33 const templates: Record<string, PromptTemplate> = {
34 function: functionTemplate,
35 string: "This is a static template",
36 };
37
38 const result = serializePromptTemplates(templates);
39
40 expect(result).toEqual({
41 function: "",
42 string: "This is a static template",
43 });
44 });
45});