import { describe, it, expect } from 'vitest';
import { isValidCommandName } from '../command-validation.js';

describe('isValidCommandName', () => {
  describe('valid command names', () => {
    it('accepts simple lowercase names', () => {
      expect(isValidCommandName('assist')).toBe(true);
    });

    it('accepts kebab-case names', () => {
      expect(isValidCommandName('code-review')).toBe(true);
    });

    it('accepts names with numbers', () => {
      expect(isValidCommandName('deploy-v2')).toBe(true);
    });

    it('accepts single character names', () => {
      expect(isValidCommandName('a')).toBe(true);
    });

    it('accepts names with only numbers', () => {
      expect(isValidCommandName('123')).toBe(true);
    });

    it('accepts names with mixed alphanumeric and hyphens', () => {
      expect(isValidCommandName('a1-b2-c3')).toBe(true);
    });

    it('accepts names starting with numbers', () => {
      expect(isValidCommandName('2fa-verify')).toBe(true);
    });
  });

  describe('invalid command names', () => {
    it('rejects uppercase letters', () => {
      expect(isValidCommandName('Assist')).toBe(false);
      expect(isValidCommandName('CODE-REVIEW')).toBe(false);
    });

    it('rejects leading hyphens', () => {
      expect(isValidCommandName('-assist')).toBe(false);
    });

    it('rejects trailing hyphens', () => {
      expect(isValidCommandName('assist-')).toBe(false);
    });

    it('rejects double hyphens', () => {
      expect(isValidCommandName('code--review')).toBe(false);
    });

    it('rejects empty strings', () => {
      expect(isValidCommandName('')).toBe(false);
    });

    it('rejects underscores', () => {
      expect(isValidCommandName('code_review')).toBe(false);
    });

    it('rejects spaces', () => {
      expect(isValidCommandName('code review')).toBe(false);
    });

    it('rejects special characters', () => {
      expect(isValidCommandName('code.review')).toBe(false);
      expect(isValidCommandName('code@review')).toBe(false);
    });
  });
});