UNPKG

cmte

Version:

Design by Committee™ except it's just you and LLMs

87 lines (79 loc) 2.63 kB
import { describe, expect, test, beforeEach, vi } from 'vitest'; import { OutputManager } from "../index.js"; import * as fs from 'fs'; // Mock fs module vi.mock('fs', () => ({ default: { existsSync: vi.fn(), statSync: vi.fn(), mkdirSync: vi.fn(), writeFileSync: vi.fn(), readFileSync: vi.fn() }, existsSync: vi.fn(), statSync: vi.fn(), mkdirSync: vi.fn(), writeFileSync: vi.fn(), readFileSync: vi.fn() })); describe('OutputManager Integration', () => { let outputManager; beforeEach(() => { outputManager = new OutputManager(true, true); // showThinking and showPrompts enabled vi.clearAllMocks(); // Setup default fs mock behavior const mockStat = { isDirectory: () => false }; fs.existsSync.mockReturnValue(true); fs.statSync.mockReturnValue(mockStat); }); describe('output path generation', () => { test('generates correct paths for thinking and response outputs', () => { // Test thinking output paths const thinkingOutputs = [ { taskName: 'analysis', index: 0 }, { taskName: 'deep-analysis', index: 1 } ]; thinkingOutputs.forEach(output => { const outputPath = outputManager.getOutputPath({ basePath: '_output/test', isThinking: true, thinkingIndex: output.index }); const promptPath = outputManager.getPromptPath({ basePath: '_output/test', isThinking: true, thinkingIndex: output.index }); expect(outputPath).toBe(`_output/test-thinking-${output.index + 1}.o.md`); expect(promptPath).toBe(`_output/test-thinking-${output.index + 1}.prompt.md`); }); // Test response output paths const responsePath = outputManager.getOutputPath({ basePath: '_output/test', isThinking: false }); const responsePromptPath = outputManager.getPromptPath({ basePath: '_output/test', isThinking: false }); expect(responsePath).toBe('_output/test.o.md'); expect(responsePromptPath).toBe('_output/test.prompt.md'); }); test('handles iteration-specific output paths', () => { const items = [ { name: 'service1', path: 'src/service1' }, { name: 'service2', path: 'src/service2' } ]; items.forEach((item, index) => { const outputPath = outputManager.getOutputPath({ basePath: `_output/test/${item.name}`, isThinking: true, thinkingIndex: 0 }); expect(outputPath).toBe(`_output/test/${item.name}-thinking-1.o.md`); }); }); }); });