import { compileHostUrl } from '../root-api'; import { expect } from '../../../test-utils'; describe('Host URL compiler', function () { it('should transform app.rootplatform.com to https://sandbox.rootplatform.com with a sandbox api key', function () { const apiKey = 'sandbox_ZDFkOTI1NGUtNDkxYy00NjhkLWFhMjYtOTY5Y2ZiMmE3ZGI0L'; const host = 'api.rootplatform.com'; const newHost = compileHostUrl({ apiKey, host }); expect(newHost).to.equals('https://sandbox.rootplatform.com'); }); it('should transform sandbox.rootplatform.com to https://sandbox.rootplatform.com with a sandbox api key', function () { const apiKey = 'sandbox_ZDFkOTI1NGUtNDkxYy00NjhkLWFhMjYtOTY5Y2ZiMmE3ZGI0L'; const host = 'sandbox.rootplatform.com'; const newHost = compileHostUrl({ apiKey, host }); expect(newHost).to.equals('https://sandbox.rootplatform.com'); }); it('should transform api.rootplatform.com to https://api.rootplatform.com with a production api key', function () { const apiKey = 'production_NDIwZGYxNGQtYjA5ZC00ZDg5LTg0YTgtOGUzMTE4YzljYT'; const host = 'api.rootplatform.com'; const newHost = compileHostUrl({ apiKey, host }); expect(newHost).to.equals('https://api.rootplatform.com'); }); it('should not break localhost url if sandbox api key', function () { const apiKey = 'sandbox_ZDFkOTI1NGUtNDkxYy00NjhkLWFhMjYtOTY5Y2ZiMmE3ZGI0L'; const host = 'http://localhost:4000'; const newHost = compileHostUrl({ apiKey, host }); expect(newHost).to.equals('http://localhost:4000'); }); it('should not break localhost url if production api key', function () { const apiKey = 'production_NDIwZGYxNGQtYjA5ZC00ZDg5LTg0YTgtOGUzMTE4YzljYT'; const host = 'http://localhost:4000'; const newHost = compileHostUrl({ apiKey, host }); expect(newHost).to.equals('http://localhost:4000'); }); });