Skip to content

Commit 36b7574

Browse files
committed
JS: add additional route handler registration tests
1 parent 117f009 commit 36b7574

File tree

5 files changed

+209
-4
lines changed

5 files changed

+209
-4
lines changed

javascript/ql/test/library-tests/frameworks/Express/src/advanced-routehandler-registration.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,23 @@ routesMap.set("b", (req, res) => console.log(req));
125125
routesMap.forEach((v, k) => app.get(k, v));
126126
app.get("a", routesMap.get("a"));
127127
app.get("b", routesMap.get("a"));
128+
129+
let method = "GET";
130+
app[method.toLowerCase()](path, (req, res) => undefined);
131+
132+
let names = ["handler-in-dynamic-require"];
133+
names.forEach(name => {
134+
let dynamicRequire = require("./controllers/" + name);
135+
app.get(dynamicRequire.path, dynamicRequire.handler);
136+
});
137+
138+
let bulkRequire = require("./controllers");
139+
app.get(bulkRequire.bulky.path, bulkRequire.bulky.handler);
140+
141+
let options = { app: app };
142+
let args = [];
143+
args.push((req, res) => undefined);
144+
app.use.apply(options.app, args);
145+
146+
let handlers = { handlerA: (req, res) => undefined};
147+
app.use(handlers.handlerA.bind(data));
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { path: "bulky", handler: (req, res) => undefined };
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { path: "/A", handler: (req, res) => undefined };
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let bulky = require("./handler-in-bulk-require");
2+
module.exports = {
3+
bulky: bulky
4+
};

0 commit comments

Comments
 (0)