/**
 * SecurityCoreModule 单元测试
 * 
 * 测试覆盖：
 * - 模块配置验证
 * - 提供者注册检查
 * - 导出验证
 * 
 * @author moyin
 * @version 1.0.0
 * @since 2026-01-07
 */

import { Test, TestingModule } from '@nestjs/testing';
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
import { SecurityCoreModule } from './security_core.module';
import { ThrottleGuard } from './throttle.guard';
import { TimeoutInterceptor } from './timeout.interceptor';

describe('SecurityCoreModule', () => {
  let module: TestingModule;

  beforeEach(async () => {
    module = await Test.createTestingModule({
      imports: [SecurityCoreModule],
    }).compile();
  });

  afterEach(async () => {
    if (module) {
      await module.close();
    }
  });

  describe('Module Configuration', () => {
    it('should be defined', () => {
      expect(module).toBeDefined();
    });

    it('should provide ThrottleGuard', () => {
      const guard = module.get<ThrottleGuard>(ThrottleGuard);
      expect(guard).toBeDefined();
      expect(guard).toBeInstanceOf(ThrottleGuard);
    });

    it('should provide TimeoutInterceptor', () => {
      const interceptor = module.get<TimeoutInterceptor>(TimeoutInterceptor);
      expect(interceptor).toBeDefined();
      expect(interceptor).toBeInstanceOf(TimeoutInterceptor);
    });

    it('should provide global providers', () => {
      // 验证模块能够正常编译和初始化
      expect(module).toBeDefined();
      
      // 验证核心组件可以被获取
      const guard = module.get<ThrottleGuard>(ThrottleGuard);
      const interceptor = module.get<TimeoutInterceptor>(TimeoutInterceptor);
      
      expect(guard).toBeDefined();
      expect(interceptor).toBeDefined();
    });
  });
});