import { PaynowGateway } from './paynow.gateway';
import { PesePayGateway } from './pesepay.gateway';

describe('Payment verification fails closed', () => {
  it('does not mark payments successful when gateway credentials are missing', async () => {
    await expect(
      new PaynowGateway({}).verifyPayment('https://www.paynow.co.zw/poll'),
    ).rejects.toThrow('credentials');
    await expect(
      new PesePayGateway({}).verifyPayment('reference'),
    ).rejects.toThrow('credentials');
  });
  it('requires a real HTTPS Paynow poll URL before making a request', async () => {
    const gateway = new PaynowGateway({
      paynowIntegrationId: 'configured',
      paynowIntegrationKey: 'configured',
    });
    for (const reference of [
      '',
      'order-reference',
      'http://example.com/poll',
    ]) {
      await expect(gateway.verifyPayment(reference)).rejects.toThrow('HTTPS');
    }
  });
  it('requires a PesePay reference before making a request', async () => {
    const gateway = new PesePayGateway({
      pesepayMerchantKey: 'configured',
      pesepayEncryptionKey: 'configured',
    });
    await expect(gateway.verifyPayment('')).rejects.toThrow('reference');
    await expect(gateway.verifyPayment('   ')).rejects.toThrow('reference');
  });
});
