import { describe, it, expect } from 'vitest';
import { isAllowedSparkCommand, SPARK_DESTRUCTIVE } from '../sparkAllowList.js';

describe('spark allow-list', () => {
  it('allows common scaffolding and maintenance commands', () => {
    expect(isAllowedSparkCommand('make:controller')).toBe(true);
    expect(isAllowedSparkCommand('make:model')).toBe(true);
    expect(isAllowedSparkCommand('migrate')).toBe(true);
    expect(isAllowedSparkCommand('routes')).toBe(true);
    expect(isAllowedSparkCommand('cache:clear')).toBe(true);
  });

  it('rejects arbitrary commands', () => {
    expect(isAllowedSparkCommand('migrate:refresh')).toBe(true); // allowed but destructive
    expect(isAllowedSparkCommand('tinker')).toBe(false);
    expect(isAllowedSparkCommand('serve')).toBe(false);
    expect(isAllowedSparkCommand('shell')).toBe(false);
  });

  it('marks migrate:refresh as destructive', () => {
    expect(SPARK_DESTRUCTIVE.has('migrate:refresh')).toBe(true);
    expect(SPARK_DESTRUCTIVE.has('make:controller')).toBe(false);
  });
});
