86 lines
2.5 KiB
TypeScript
86 lines
2.5 KiB
TypeScript
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
import * as agentsModule from "./agents";
|
|
|
|
// Mock getDb
|
|
vi.mock("./db", () => ({
|
|
getDb: vi.fn(async () => null),
|
|
}));
|
|
|
|
describe("Agents Module", () => {
|
|
describe("createAgent", () => {
|
|
it("should return null when database is unavailable", async () => {
|
|
const result = await agentsModule.createAgent(1, {
|
|
name: "Test Agent",
|
|
role: "developer",
|
|
model: "gpt-4o",
|
|
provider: "openai",
|
|
});
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("getAgentById", () => {
|
|
it("should return null when database is unavailable", async () => {
|
|
const result = await agentsModule.getAgentById(1);
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("getUserAgents", () => {
|
|
it("should return empty array when database is unavailable", async () => {
|
|
const result = await agentsModule.getUserAgents(1);
|
|
expect(result).toEqual([]);
|
|
});
|
|
});
|
|
|
|
describe("getAgentStats", () => {
|
|
it("should return null when database is unavailable", async () => {
|
|
const result = await agentsModule.getAgentStats(1);
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("getAgentMetrics", () => {
|
|
it("should return empty array when database is unavailable", async () => {
|
|
const result = await agentsModule.getAgentMetrics(1);
|
|
expect(result).toEqual([]);
|
|
});
|
|
});
|
|
|
|
describe("getAgentHistory", () => {
|
|
it("should return empty array when database is unavailable", async () => {
|
|
const result = await agentsModule.getAgentHistory(1);
|
|
expect(result).toEqual([]);
|
|
});
|
|
});
|
|
|
|
describe("getAgentAccessControl", () => {
|
|
it("should return empty array when database is unavailable", async () => {
|
|
const result = await agentsModule.getAgentAccessControl(1);
|
|
expect(result).toEqual([]);
|
|
});
|
|
});
|
|
|
|
describe("getAllAgents", () => {
|
|
it("should return empty array when database is unavailable", async () => {
|
|
const result = await agentsModule.getAllAgents();
|
|
expect(result).toEqual([]);
|
|
});
|
|
|
|
it("should be exported from agents module", () => {
|
|
expect(typeof agentsModule.getAllAgents).toBe("function");
|
|
});
|
|
});
|
|
|
|
describe("getSystemAgents", () => {
|
|
it("should return empty array when database is unavailable", async () => {
|
|
const result = await agentsModule.getSystemAgents();
|
|
expect(result).toEqual([]);
|
|
});
|
|
|
|
it("should be exported from agents module", () => {
|
|
expect(typeof agentsModule.getSystemAgents).toBe("function");
|
|
});
|
|
});
|
|
});
|