import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import { tmpdir } from 'os';
import { executeResetSlides } from './reset-slides.js';
import { appendSlide, setTheme, readSlidesDoc } from './state.js';

describe('ResetSlides', () => {
  let ws: string;
  beforeEach(() => { ws = fs.mkdtempSync(path.join(tmpdir(), 'slide-rs-')); });
  afterEach(() => { fs.rmSync(ws, { recursive: true, force: true }); });

  it('clears slides[] but keeps theme', async () => {
    setTheme(ws, { preset: 'vibrant', overrides: {} });
    appendSlide(ws, { layout: 'title', content: { title: 'A' }, notes: null });
    appendSlide(ws, { layout: 'bullets', content: { title: 'B', bullets: ['x'] }, notes: null });
    const r = await executeResetSlides({}, { workspacePath: ws } as any);
    expect(r.isError).toBeFalsy();
    const doc = readSlidesDoc(ws);
    expect(doc.slides).toHaveLength(0);
    expect(doc.theme.preset).toBe('vibrant');
  });
});
