Some checks failed
CI / test (map[image:macos-latest name:macos], 1, 4) (push) Has been cancelled
CI / test (map[image:macos-latest name:macos], 2, 4) (push) Has been cancelled
CI / test (map[image:macos-latest name:macos], 3, 4) (push) Has been cancelled
CI / test (map[image:macos-latest name:macos], 4, 4) (push) Has been cancelled
CI / test (map[image:windows-latest name:windows], 1, 4) (push) Has been cancelled
CI / test (map[image:windows-latest name:windows], 2, 4) (push) Has been cancelled
CI / test (map[image:windows-latest name:windows], 3, 4) (push) Has been cancelled
CI / test (map[image:windows-latest name:windows], 4, 4) (push) Has been cancelled
CI / merge-reports (push) Has been cancelled
- Added a new integration script to manage custom features related to smart context. - Implemented handlers for smart context operations (get, update, clear, stats) in ipc. - Created a SmartContextStore class to manage context snippets and summaries. - Developed hooks for React to interact with smart context (useSmartContext, useUpdateSmartContext, useClearSmartContext, useSmartContextStats). - Included backup and restore functionality in the integration script. - Validated integration by checking for custom modifications and file existence.
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { replacePromptReference } from "@/ipc/utils/replacePromptReference";
|
|
|
|
describe("replacePromptReference", () => {
|
|
it("returns original when no references present", () => {
|
|
const input = "Hello world";
|
|
const output = replacePromptReference(input, {});
|
|
expect(output).toBe(input);
|
|
});
|
|
|
|
it("replaces a single @prompt:id with content", () => {
|
|
const input = "Use this: @prompt:42";
|
|
const prompts = { 42: "Meaning of life" };
|
|
const output = replacePromptReference(input, prompts);
|
|
expect(output).toBe("Use this: Meaning of life");
|
|
});
|
|
|
|
it("replaces multiple occurrences and keeps surrounding text", () => {
|
|
const input = "A @prompt:1 and B @prompt:2 end";
|
|
const prompts = { 1: "One", 2: "Two" };
|
|
const output = replacePromptReference(input, prompts);
|
|
expect(output).toBe("A One and B Two end");
|
|
});
|
|
|
|
it("leaves unknown references intact", () => {
|
|
const input = "Unknown @prompt:99 here";
|
|
const prompts = { 1: "One" };
|
|
const output = replacePromptReference(input, prompts);
|
|
expect(output).toBe("Unknown @prompt:99 here");
|
|
});
|
|
|
|
it("supports string keys in map as well as numeric", () => {
|
|
const input = "Mix @prompt:7 and @prompt:8";
|
|
const prompts = { "7": "Seven", 8: "Eight" } as Record<
|
|
string | number,
|
|
string
|
|
>;
|
|
const output = replacePromptReference(input, prompts);
|
|
expect(output).toBe("Mix Seven and Eight");
|
|
});
|
|
});
|