From 0ebac19f9be3327cb228c65f41d746dc6da59e46 Mon Sep 17 00:00:00 2001 From: chimurai <655241+chimurai@users.noreply.github.com> Date: Fri, 15 Apr 2022 19:53:30 +0200 Subject: [PATCH] test(path-rewriter): improve coverage --- test/e2e/path-rewriter.spec.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/e2e/path-rewriter.spec.ts b/test/e2e/path-rewriter.spec.ts index 0b0de362..3fc2c981 100644 --- a/test/e2e/path-rewriter.spec.ts +++ b/test/e2e/path-rewriter.spec.ts @@ -56,4 +56,26 @@ describe('E2E pathRewrite', () => { expect(response.text).toBe('/API RESPONSE AFTER PATH REWRITE FUNCTION'); }); }); + + describe('Rewrite paths with function which return undefined', () => { + it('should proxy with requested path', async () => { + mockTargetServer + .get('/api/lorum/ipsum') + .thenReply(200, '/API RESPONSE AFTER PATH REWRITE FUNCTION'); + + const agent = request( + createApp( + createProxyMiddleware({ + target: `http://localhost:${mockTargetServer.port}`, + pathRewrite(path, req) { + return undefined; + }, + }) + ) + ); + + const response = await agent.get('/api/lorum/ipsum').expect(200); + expect(response.text).toBe('/API RESPONSE AFTER PATH REWRITE FUNCTION'); + }); + }); });