import { occupancyWhereOnDate } from './room-occupancy-date';

describe('occupancyWhereOnDate', () => {
  it('treats checkout date as the first day no longer occupying the old room', () => {
    const where = occupancyWhereOnDate('2026-07-22', 10);

    expect(where).toHaveLength(2);
    expect(where[0]).toEqual(
      expect.objectContaining({ roomId: 10, checkInDate: expect.anything(), checkOutDate: expect.anything() }),
    );
    expect(where[1]).toEqual(
      expect.objectContaining({ roomId: 10, checkInDate: expect.anything(), checkOutDate: expect.anything() }),
    );
    expect(String((where[1] as any).checkOutDate._type)).toBe('moreThan');
    expect((where[1] as any).checkOutDate._value).toBe('2026-07-22');
  });

  it('can query all rooms for automatic settlement', () => {
    const where = occupancyWhereOnDate('2026-07-22');
    expect(where.every((condition) => condition.roomId === undefined)).toBe(true);
  });
});
