import { describe, it, expect } from 'vitest';
import { GetListingQuery } from '../queries/get-listing/get-listing.query';
import { GetPendingModerationQuery } from '../queries/get-pending-moderation/get-pending-moderation.query';
import { SearchListingsQuery } from '../queries/search-listings/search-listings.query';

describe('GetListingQuery', () => {
  it('should store listingId', () => {
    const query = new GetListingQuery('listing-1');
    expect(query.listingId).toBe('listing-1');
  });

  it('should store different listing IDs', () => {
    const query1 = new GetListingQuery('a1b2c3d4');
    const query2 = new GetListingQuery('e5f6g7h8');

    expect(query1.listingId).toBe('a1b2c3d4');
    expect(query2.listingId).toBe('e5f6g7h8');
    expect(query1.listingId).not.toBe(query2.listingId);
  });
});

describe('GetPendingModerationQuery', () => {
  it('should use default page and limit', () => {
    const query = new GetPendingModerationQuery();
    expect(query.page).toBe(1);
    expect(query.limit).toBe(20);
  });

  it('should accept custom page and limit', () => {
    const query = new GetPendingModerationQuery(3, 50);
    expect(query.page).toBe(3);
    expect(query.limit).toBe(50);
  });

  it('should accept custom page with default limit', () => {
    const query = new GetPendingModerationQuery(2);
    expect(query.page).toBe(2);
    expect(query.limit).toBe(20);
  });
});

describe('SearchListingsQuery', () => {
  it('should use defaults when no params provided', () => {
    const query = new SearchListingsQuery();
    expect(query.status).toBeUndefined();
    expect(query.transactionType).toBeUndefined();
    expect(query.propertyType).toBeUndefined();
    expect(query.city).toBeUndefined();
    expect(query.district).toBeUndefined();
    expect(query.minPrice).toBeUndefined();
    expect(query.maxPrice).toBeUndefined();
    expect(query.minArea).toBeUndefined();
    expect(query.maxArea).toBeUndefined();
    expect(query.bedrooms).toBeUndefined();
    expect(query.page).toBe(1);
    expect(query.limit).toBe(20);
  });

  it('should store all filter parameters', () => {
    const query = new SearchListingsQuery(
      'ACTIVE',
      'SALE',
      'APARTMENT',
      'Hồ Chí Minh',
      'Quận 1',
      2_000_000_000n,
      10_000_000_000n,
      50,
      200,
      2,
      1,
      20,
    );

    expect(query.status).toBe('ACTIVE');
    expect(query.transactionType).toBe('SALE');
    expect(query.propertyType).toBe('APARTMENT');
    expect(query.city).toBe('Hồ Chí Minh');
    expect(query.district).toBe('Quận 1');
    expect(query.minPrice).toBe(2_000_000_000n);
    expect(query.maxPrice).toBe(10_000_000_000n);
    expect(query.minArea).toBe(50);
    expect(query.maxArea).toBe(200);
    expect(query.bedrooms).toBe(2);
    expect(query.page).toBe(1);
    expect(query.limit).toBe(20);
  });

  it('should allow partial filter parameters', () => {
    const query = new SearchListingsQuery(
      'ACTIVE',
      undefined,
      'VILLA',
      'Hồ Chí Minh',
    );

    expect(query.status).toBe('ACTIVE');
    expect(query.transactionType).toBeUndefined();
    expect(query.propertyType).toBe('VILLA');
    expect(query.city).toBe('Hồ Chí Minh');
    expect(query.district).toBeUndefined();
  });
});
