import { validate } from 'class-validator';
import { describe, it, expect } from 'vitest';
import { VerifyKycDto } from '../dto/verify-kyc.dto';

describe('VerifyKycDto', () => {
  it('accepts valid KYC data with VERIFIED status', async () => {
    const dto = new VerifyKycDto();
    dto.kycStatus = 'VERIFIED' as any;
    const errors = await validate(dto);
    expect(errors).toHaveLength(0);
  });

  it('accepts valid KYC data with REJECTED status', async () => {
    const dto = new VerifyKycDto();
    dto.kycStatus = 'REJECTED' as any;
    const errors = await validate(dto);
    expect(errors).toHaveLength(0);
  });

  it('accepts KYC data with optional kycData object', async () => {
    const dto = new VerifyKycDto();
    dto.kycStatus = 'VERIFIED' as any;
    dto.kycData = { idNumber: '123456789', issueDate: '2024-01-01' };
    const errors = await validate(dto);
    expect(errors).toHaveLength(0);
  });

  it('rejects invalid kycStatus enum value', async () => {
    const dto = new VerifyKycDto();
    dto.kycStatus = 'INVALID_STATUS' as any;
    const errors = await validate(dto);
    expect(errors.length).toBeGreaterThan(0);
    expect(errors.some((e) => e.property === 'kycStatus')).toBe(true);
  });

  it('rejects missing kycStatus', async () => {
    const dto = new VerifyKycDto();
    const errors = await validate(dto);
    expect(errors.length).toBeGreaterThan(0);
    expect(errors.some((e) => e.property === 'kycStatus')).toBe(true);
  });

  it('rejects non-object kycData', async () => {
    const dto = new VerifyKycDto();
    dto.kycStatus = 'VERIFIED' as any;
    (dto as any).kycData = 'not-an-object';
    const errors = await validate(dto);
    expect(errors.length).toBeGreaterThan(0);
    expect(errors.some((e) => e.property === 'kycData')).toBe(true);
  });
});
