text: const ReturnsApiClient = require('internal/lib/connectors/services/returns/ReturnsApiClient');
  const { serviceRequest } = require('@envage/water-abstraction-helpers');
  
  const {
    experiment,
    test,
    beforeEach,
    afterEach
  } = exports.lab = require('@hapi/lab').script();
  const { expect } = require('@hapi/code');
  
  const sinon = require('sinon');
  const sandbox = sinon.createSandbox();
  
  experiment('internal/services/ReturnsApiClient', () => {
    let logger;
    let config;
    let client;
  
    beforeEach(async () => {
      logger = {};
      config = {
        jwt: {
          token: 'test-jwt-token'
        },
        services: {
          returns: 'https://example.com/returns'
        }
      };
  
      client = new ReturnsApiClient(config, logger);
      sandbox.stub(serviceRequest, 'get').resolves({});
    });
  
    afterEach(async () => {
      sandbox.restore();
    });
  
    experiment('construction', () => {
      test('creates the expected endpoint URL', async () => {
        expect(client.getUrl()).to.equal('https://example.com/returns/returns');
      });
  
      test('sets the JWT in the client headers', async () => {
        expect(client.config.headers.Authorization).to.equal('test-jwt-token');
      });
  
      test('adds the base service URL to the config', async () => {
        expect(client.config.serviceUrl).to.equal('https://example.com/returns');
      });
    });
  });
  