UNPKG

taskforce-aiagent

Version:

TaskForce is a modular, open-source, production-ready TypeScript agent framework for orchestrating AI agents, LLM-powered autonomous agents, task pipelines, dynamic toolchains, RAG workflows and memory/retrieval systems.

44 lines (43 loc) 1.98 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); // @ts-nocheck const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const prompt_helper_1 = require("./prompt.helper"); // Jest'in fs modülünü mock'layalım: jest.mock("fs"); describe("loadPromptFromFile", () => { beforeEach(() => { jest.clearAllMocks(); }); it("should load prompt content from absolute file path", () => { // Arrange const mockFilePath = "/absolute/mock/prompt.txt"; const mockContent = "prompt content"; fs_1.default.existsSync.mockReturnValue(true); fs_1.default.readFileSync.mockReturnValue(mockContent); // Act const result = (0, prompt_helper_1.loadPromptFromFile)(mockFilePath); // Assert expect(fs_1.default.existsSync).toHaveBeenCalledWith(mockFilePath); expect(fs_1.default.readFileSync).toHaveBeenCalledWith(mockFilePath, "utf-8"); expect(result).toBe(mockContent); }); it("should load prompt content from relative file path", () => { const relPath = "mock/relative.txt"; const absPath = path_1.default.join(process.cwd(), relPath); fs_1.default.existsSync.mockReturnValue(true); fs_1.default.readFileSync.mockReturnValue("hello"); const result = (0, prompt_helper_1.loadPromptFromFile)(relPath); expect(fs_1.default.existsSync).toHaveBeenCalledWith(absPath); expect(fs_1.default.readFileSync).toHaveBeenCalledWith(absPath, "utf-8"); expect(result).toBe("hello"); }); it("should throw if file does not exist", () => { fs_1.default.existsSync.mockReturnValue(false); expect(() => (0, prompt_helper_1.loadPromptFromFile)("/does/not/exist.txt")).toThrow("Prompt file not found"); }); });