UNPKG

@meldscience/meld

Version:

pipeable one-shot prompt scripting toolkit

43 lines (36 loc) 1.05 kB
import { vi } from 'vitest'; import { AIProvider } from '../src/providers/anthropic'; // Mock fs module export const mockFs = { readFileSync: vi.fn(), writeFileSync: vi.fn(), existsSync: vi.fn(), unlinkSync: vi.fn(), }; // Mock os module export const mockOs = { homedir: vi.fn().mockReturnValue('/mock/home'), }; // Mock child_process module export const mockChildProcess = { execSync: vi.fn(), }; // Mock AI provider for testing export class MockAIProvider implements AIProvider { constructor(private mockResponse: string = 'mock response') {} async sendPrompt(): Promise<string> { return this.mockResponse; } } // Helper to create temp files for testing export function createTempMarkdown(content: string): string { const tempPath = `.temp-${Date.now()}.md`; mockFs.writeFileSync(tempPath, content, 'utf-8'); return tempPath; } // Setup function to reset all mocks export function setupMocks() { vi.mock('fs', () => mockFs); vi.mock('os', () => mockOs); vi.mock('child_process', () => mockChildProcess); }