From dbcd4a98743c39a40e736a3c9a9b2b901b378e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Thu, 14 Mar 2019 09:17:52 +0100 Subject: [PATCH] test(testlab): verify how RequestContext combines urlBase and basePath --- .../integration/request-context.integration.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/rest/src/__tests__/integration/request-context.integration.ts b/packages/rest/src/__tests__/integration/request-context.integration.ts index 96777c0977b7..195e0793b6c8 100644 --- a/packages/rest/src/__tests__/integration/request-context.integration.ts +++ b/packages/rest/src/__tests__/integration/request-context.integration.ts @@ -73,6 +73,21 @@ describe('RequestContext', () => { expect(observedCtx.basePath).to.equal('/api'); }); + + it('combines both baseUrl and basePath', async () => { + const lbApp = new RestApplication(); + lbApp.handler(contextObservingHandler); + lbApp.basePath('/v1'); // set basePath at LoopBack level + + const expressApp = express(); + expressApp.use('/api', lbApp.requestHandler); // mount the app at baseUrl + + await supertest(expressApp) + .get('/api/v1/products') + .expect(200); + + expect(observedCtx.basePath).to.equal('/api/v1'); + }); }); describe('requestedBaseUrl', () => {