import { describe, it, expect, beforeEach, vi } from '@jest/globals';
import { RuleEngineService } from '../../core/engine/RuleEngineService';

describe('RuleEngineService', () => {
  let ruleEngineService: RuleEngineService;

  beforeEach(() => {
    ruleEngineService = new RuleEngineService();
  });

  describe('executeRules', () => {
    it('should execute rules and return result', async () => {
      const request = { id: '1', type: 'test' };
      const context = { tenantId: 'test-tenant' };

      const result = await ruleEngineService.executeRules(request, context);

      expect(result).toHaveProperty('workflowId');
      expect(result).toHaveProperty('data');
    });
  });

  describe('registerRule', () => {
    it('should register rule and return rule id', async () => {
      const rule = { id: 'rule-1', condition: 'test condition' };

      const result = await ruleEngineService.registerRule(rule);

      expect(typeof result).toBe('string');
    });
  });

  describe('getStatus', () => {
    it('should return rule engine status', async () => {
      const result = await ruleEngineService.getStatus();
      expect(result).toHaveProperty('status');
    });
  });
});
