import { expect } from '../../../test-utils'; import { getSandboxHost } from '../get-sandbox-host'; describe('getSandboxHost', () => { it('should rewrite https://api. to https://sandbox.', () => { const result = getSandboxHost('https://api.rootplatform.com'); expect(result).to.equal('https://sandbox.rootplatform.com'); }); it('should rewrite http://api. to http://sandbox.', () => { const result = getSandboxHost('http://api.rootplatform.com'); expect(result).to.equal('http://sandbox.rootplatform.com'); }); it('should leave an already-sandbox host unchanged', () => { const result = getSandboxHost('https://sandbox.rootplatform.com'); expect(result).to.equal('https://sandbox.rootplatform.com'); }); it('should leave localhost unchanged', () => { const result = getSandboxHost('http://localhost:4000'); expect(result).to.equal('http://localhost:4000'); }); it('should only rewrite the api. subdomain prefix, not api elsewhere in the host', () => { const result = getSandboxHost('https://api.customer-api.example.com'); expect(result).to.equal('https://sandbox.customer-api.example.com'); }); });