import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { mkdtempSync, rmSync } from 'fs'; import { tmpdir } from 'os'; import { join } from 'path'; import { createDecision, listDecisions, getDecision } from '../src/core/services/decisionService.js'; describe('decisionService', () => { let cwd: string; beforeEach(() => { cwd = mkdtempSync(join(tmpdir(), 'ah-dec-')); }); afterEach(() => { rmSync(cwd, { recursive: true, force: true }); }); it('creates and reads a decision', () => { const d = createDecision(cwd, { title: 'Use SQLite', context: 'c', decision: 'd' }); expect(d.id).toBe('DEC-0001'); expect(getDecision(cwd, d.id).decision.title).toBe('Use SQLite'); expect(listDecisions(cwd)).toHaveLength(1); }); });