gadget/docs/archive/services/__tests__/chat.service.test.ts

119 lines
2.8 KiB
TypeScript

// src/services/__tests__/chat.service.test.ts
// Copyright (C) 2026 DTP Technologies, LLC
// All Rights Reserved
import { describe, it, expect } from "vitest";
describe("ChatService Types", () => {
describe("ChatSessionMode enum values", () => {
it("should have Plan mode", () => {
const mode = "plan";
expect(mode).toBe("plan");
});
it("should have Build mode", () => {
const mode = "build";
expect(mode).toBe("build");
});
it("should have Test mode", () => {
const mode = "test";
expect(mode).toBe("test");
});
it("should have Ship mode", () => {
const mode = "ship";
expect(mode).toBe("ship");
});
it("should have Develop mode", () => {
const mode = "dev";
expect(mode).toBe("dev");
});
});
describe("ChatSessionType enum values", () => {
it("should have Desktop type", () => {
const type = "desktop";
expect(type).toBe("desktop");
});
it("should have Mobile type", () => {
const type = "mobile";
expect(type).toBe("mobile");
});
it("should have Extension type", () => {
const type = "extension";
expect(type).toBe("extension");
});
});
describe("IChatSessionListItem interface", () => {
const session = {
_id: "507f1f77bcf86cd799439011",
name: "Test Session",
lastMessageAt: new Date(),
turnCount: 5,
toolCallCount: 10,
inputTokens: 1000,
outputTokens: 2000,
createdAt: new Date(),
mode: "build",
};
it("should have _id", () => {
expect(session._id).toBeDefined();
});
it("should have name", () => {
expect(session.name).toBe("Test Session");
});
it("should have turnCount", () => {
expect(session.turnCount).toBe(5);
});
it("should have inputTokens", () => {
expect(session.inputTokens).toBe(1000);
});
it("should have outputTokens", () => {
expect(session.outputTokens).toBe(2000);
});
});
describe("IChatSessionDetail extended interface", () => {
const detail = {
_id: "507f1f77bcf86cd799439011",
name: "Test Session",
lastMessageAt: new Date(),
turnCount: 5,
toolCallCount: 10,
inputTokens: 1000,
outputTokens: 2000,
createdAt: new Date(),
mode: "build",
user: "507f1f77bcf86cd799439012",
project: "My Project",
type: "desktop" as const,
pins: [{ content: "pin1" }],
};
it("should have user field for ownership", () => {
expect(detail.user).toBeDefined();
});
it("should have project field", () => {
expect(detail.project).toBe("My Project");
});
it("should have type field", () => {
expect(detail.type).toBe("desktop");
});
it("should have pins array", () => {
expect(Array.isArray(detail.pins)).toBe(true);
});
});
});