import { describe, expect, test } from "bun:test"; import { jest, describe, beforeEach, it, expect } from '@jest/globals'; import { z } from 'zod'; import { DomainSchema } from '../../src/schemas.js'; type MockResponse = { success: boolean }; // Define types for tool and server interface Tool { name: string; description: string; execute: (params: any) => Promise; parameters: z.ZodType; } interface MockService { [key: string]: jest.Mock>; } interface MockServices { light: { turn_on: jest.Mock>; turn_off: jest.Mock>; }; climate: { set_temperature: jest.Mock>; }; } interface MockHassInstance { services: MockServices; } // Mock LiteMCP class class MockLiteMCP { private tools: Tool[] = []; constructor(public name: string, public version: string) { } addTool(tool: Tool) { this.tools.push(tool); } getTools() { return this.tools; } } const createMockFn = (): jest.Mock> => { return jest.fn<() => Promise>().mockResolvedValue({ success: true }); }; // Mock the Home Assistant instance const mockHassServices: MockHassInstance = { services: { light: { turn_on: createMockFn(), turn_off: createMockFn(), }, climate: { set_temperature: createMockFn(), }, }, }; // Mock get_hass function const get_hass = jest.fn<() => Promise>().mockResolvedValue(mockHassServices); describe('Context Tests', () => { let mockTool: Tool; beforeEach(() => { mockTool = { name: 'test_tool', description: 'A test tool', execute: jest.fn<(params: any) => Promise>().mockResolvedValue({ success: true }), parameters: z.object({ test: z.string() }) }; }); // Add your test cases here test('should execute tool successfully', async () => { const result = await mockTool.execute({ test: 'value' }); expect(result.success).toBe(true); }); });