Skip to content

Commit

Permalink
test(path-rewriter): improve coverage (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
chimurai committed Apr 16, 2022
1 parent 468db39 commit 1338ea0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/e2e/path-rewriter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});

0 comments on commit 1338ea0

Please sign in to comment.