import { AssessmentCommandParser } from './assessment-command.parser';
import { AssessmentCommandType } from '../dto/assessment-command.dto';

describe('AssessmentCommandParser', () => {
  let parser: AssessmentCommandParser;

  beforeEach(() => {
    parser = new AssessmentCommandParser();
  });

  describe('parse', () => {
    it('should parse start command without parameters', () => {
      const result = parser.parse('/assessment start');
      expect(result).toMatchObject({
        type: AssessmentCommandType.START,
        parameters: [],
      });
    });

    it('should parse start command with parameters', () => {
      const result = parser.parse('/assessment start kb_123');
      expect(result).toMatchObject({
        type: AssessmentCommandType.START,
        parameters: ['kb_123'],
      });
    });

    it('should parse answer command', () => {
      const result = parser.parse('/assessment answer my answer');
      expect(result).toMatchObject({
        type: AssessmentCommandType.ANSWER,
        parameters: ['my', 'answer'],
      });
    });

    it('should parse Chinese commands', () => {
      const result = parser.parse('/测评 开始');
      expect(result).toMatchObject({
        type: AssessmentCommandType.START,
        parameters: [],
      });
    });

    it('should return null for non-assessment commands', () => {
      const result = parser.parse('hello world');
      expect(result).toBeNull();
    });
  });

  describe('isAssessmentCommand', () => {
    it('should return true for valid commands', () => {
      expect(parser.isAssessmentCommand('/assessment status')).toBe(true);
      expect(parser.isAssessmentCommand('/测评 状态')).toBe(true);
    });

    it('should return false for invalid commands', () => {
      expect(parser.isAssessmentCommand('status')).toBe(false);
      expect(parser.isAssessmentCommand('/status')).toBe(false);
    });
  });
});
