import { describe, it, expect } from 'vitest';
import path from 'path';
import { scanDirectory } from '../../src/services/fsScanner';

const fixturesDir = path.join(__dirname, '..', 'fixtures');
const emptyDir = path.join(fixturesDir, 'empty');

describe('services/fsScanner', () => {
  it('exporta scanDirectory', () => {
    expect(typeof scanDirectory).toBe('function');
  });

  it('carpeta vacía devuelve array', async () => {
    const res = await scanDirectory(emptyDir);
    expect(Array.isArray(res)).toBe(true);
    expect((res as any[]).length).toBe(0);
  });

  it('detecta simple-rom.bin', async () => {
    const res = await scanDirectory(fixturesDir);
    const found = (res as any[]).find(
      (r: any) => r.filename === 'simple-rom.bin' || r.name === 'simple-rom.bin'
    );
    expect(found).toBeTruthy();
    expect(found.size).toBeGreaterThan(0);
    expect(found.format).toBeDefined();
  });
});
