Elffuss BraidHub

kikocis/continue public

main · 1.3 KiBRawPermalink
1import { vi } from "vitest";
2
3// Create mock objects that will be used by tests
4export const mockUseService = vi.fn();
5export const mockUseServices = vi.fn();
6export const mockUseChat = vi.fn();
7export const mockServiceContainer = {
8 getSync: vi.fn(),
9 isReady: vi.fn(),
10 on: vi.fn(),
11 off: vi.fn(),
12 load: vi.fn(),
13 reload: vi.fn(),
14 emit: vi.fn(),
15 setMaxListeners: vi.fn(),
16};
17
18export function createMinimalTestContext() {
19 // Reset mock implementations
20 mockUseService.mockReturnValue({
21 value: null,
22 state: "idle",
23 error: null,
24 reload: vi.fn(),
25 });
26
27 mockUseServices.mockReturnValue({
28 services: {},
29 loading: false,
30 error: null,
31 allReady: true,
32 });
33
34 mockUseChat.mockReturnValue({
35 messages: [],
36 setMessages: vi.fn(),
37 chatHistory: [],
38 setChatHistory: vi.fn(),
39 isWaitingForResponse: false,
40 responseStartTime: null,
41 inputMode: true,
42 attachedFiles: [],
43 handleUserMessage: vi.fn(),
44 handleInterrupt: vi.fn(),
45 handleFileAttached: vi.fn(),
46 resetChatHistory: vi.fn(),
47 });
48
49 mockServiceContainer.getSync.mockReturnValue({
50 state: "ready",
51 value: {},
52 error: null,
53 });
54 mockServiceContainer.isReady.mockReturnValue(true);
55
56 return {
57 cleanup: () => {
58 vi.clearAllMocks();
59 },
60 };
61}