Skip to content

Commit 3b1a481

Browse files
committed
Add test for base path
1 parent dbaa630 commit 3b1a481

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/process-request.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ const processRequest = require('../lib/process-request');
99
function createApp(options) {
1010
const app = express();
1111
app.use(bodyParser.json());
12+
13+
const router = express.Router();
14+
15+
router.get('/a', (req, res) => res.json(processRequest(req, options)));
16+
17+
app.use('/test-base-path', router);
18+
1219
app.post('/*', (req, res) => {
1320
res.json(processRequest(req, options));
1421
});
@@ -56,6 +63,15 @@ describe('processRequest()', () => {
5663
// This regex is for supertest's random port numbers
5764
.expect(({ body }) => assert(body.url.match(/http:\/\/127.0.0.1:\d+\/path\?a=b/))));
5865

66+
it('#url-basepath', () =>
67+
request(createApp())
68+
.post('/test-base-path/a')
69+
.query({ a: 'b' })
70+
// This regex is for supertest's random port numbers
71+
.expect(({ body }) =>
72+
assert(body.url.match(/http:\/\/127.0.0.1:\d+\/test-base-path\/a\?a=b/)),
73+
));
74+
5975
it('#url with x-forwarded-host', () =>
6076
request(createApp())
6177
.post('/path')

0 commit comments

Comments
 (0)