import { PaymentSettlementRepository } from './payment-settlement.repository';
import { CLS_TENANT_ID } from '../../../common/cls/cls.constants';

describe('PaymentSettlementRepository.findByIdWithDetail', () => {
  it('loads the booking and guest that the invoice, receipt and detail page print', async () => {
    const findOne = jest.fn().mockResolvedValue(null);
    const cls = { get: (k: string) => (k === CLS_TENANT_ID ? 't1' : null) };
    const repo = new PaymentSettlementRepository({ findOne } as never, cls as never);

    await repo.findByIdWithDetail('s1');

    const options = findOne.mock.calls[0][0];
    expect(options.relations.booking).toEqual({ query: true });
    expect(options.where).toMatchObject({ id: 's1', tenant_id: 't1' });
  });
});
