import { type KycQueueResult } from '../../domain/repositories/admin-query.repository';
import { GetKycQueueHandler } from '../queries/get-kyc-queue/get-kyc-queue.handler';
import { GetKycQueueQuery } from '../queries/get-kyc-queue/get-kyc-queue.query';

describe('GetKycQueueHandler', () => {
  let handler: GetKycQueueHandler;
  let mockRepo: { getKycQueue: ReturnType<typeof vi.fn> };

  beforeEach(() => {
    mockRepo = {
      getKycQueue: vi.fn(),
    };
    handler = new GetKycQueueHandler(mockRepo as any);
  });

  it('returns paginated KYC queue', async () => {
    const expected: KycQueueResult = {
      data: [
        {
          userId: 'u1',
          fullName: 'Test User',
          email: 'test@test.com',
          phone: '0901234567',
          role: 'SELLER',
          kycStatus: 'PENDING',
          kycData: { idNumber: '123456789' },
          createdAt: new Date(),
        },
      ],
      total: 1,
      page: 1,
      limit: 20,
      totalPages: 1,
    };
    mockRepo.getKycQueue.mockResolvedValue(expected);

    const query = new GetKycQueueQuery(1, 20);
    const result = await handler.execute(query);

    expect(result).toEqual(expected);
    expect(mockRepo.getKycQueue).toHaveBeenCalledWith(1, 20);
  });
});
