Skip to content

Commit ba27814

Browse files
authored
fix bug with res.del when the first arguments it's a function (#35)
* fix bug with res.del when the first arguments it's a function * test: add more tests * test: add some test * test: add more test for delete method
1 parent 7f39394 commit ba27814

File tree

13 files changed

+185
-4
lines changed

13 files changed

+185
-4
lines changed

transforms/__testfixtures__/v4-deprecated-signatures/delete.input.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,37 @@ import express from "express";
33
const app = express();
44

55
app.get("/", (req, res) => {});
6+
7+
app.del([""],() => {
8+
myImportantLogic();
9+
});
10+
11+
app.del([],() => {
12+
myImportantLogic();
13+
});
14+
15+
app.del(/d/,() => {
16+
myImportantLogic();
17+
});
18+
19+
app.del(() => {
20+
myImportantLogic();
21+
});
22+
23+
app.del(function () {
24+
myImportantLogic();
25+
});
26+
627
app.del("/old", () => {
728
myImportantLogic();
829
});
930

31+
function noModify() {
32+
let a
33+
34+
app.del(a)
35+
}
36+
1037
const myImportantLogic = () => {
1138
console.log("making sure it's there");
1239
};

transforms/__testfixtures__/v4-deprecated-signatures/delete.output.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,37 @@ import express from "express";
33
const app = express();
44

55
app.get("/", (req, res) => {});
6+
7+
app.delete([""],() => {
8+
myImportantLogic();
9+
});
10+
11+
app.delete([],() => {
12+
myImportantLogic();
13+
});
14+
15+
app.delete(/d/,() => {
16+
myImportantLogic();
17+
});
18+
19+
app.del(() => {
20+
myImportantLogic();
21+
});
22+
23+
app.del(function () {
24+
myImportantLogic();
25+
});
26+
627
app.delete("/old", () => {
728
myImportantLogic();
829
});
930

31+
function noModify() {
32+
let a
33+
34+
app.del(a)
35+
}
36+
1037
const myImportantLogic = () => {
1138
console.log("making sure it's there");
1239
};

transforms/__testfixtures__/v4-deprecated-signatures/json.input.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ import express from "express";
22

33
const app = express();
44

5+
app.get("/json", function (...arg) {
6+
const [, res] = arg
7+
res.json();
8+
});
9+
10+
app.get("/json", function (...arg) {
11+
const [, res] = arg
12+
res.json({ user: "Username", isValid: true }, 200);
13+
});
14+
15+
app.get("/json", function (req, res) {
16+
res.json();
17+
});
18+
519
app.get("/json", function (req, res) {
620
res.json({ user: "Username", isValid: true }, 200);
721
});

transforms/__testfixtures__/v4-deprecated-signatures/json.output.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ import express from "express";
22

33
const app = express();
44

5+
app.get("/json", function (...arg) {
6+
const [, res] = arg
7+
res.json();
8+
});
9+
10+
app.get("/json", function (...arg) {
11+
const [, res] = arg
12+
res.status(200).json({ user: "Username", isValid: true });
13+
});
14+
15+
app.get("/json", function (req, res) {
16+
res.json();
17+
});
18+
519
app.get("/json", function (req, res) {
620
res.status(200).json({ user: "Username", isValid: true });
721
});

transforms/__testfixtures__/v4-deprecated-signatures/jsonp.input.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import express from "express";
22

33
const app = express();
44

5+
app.get("/json", function (req, res) {
6+
res.json();
7+
});
8+
59
app.get("/jsonp", function (req, res) {
610
res.jsonp({ user: "Username", isValid: true }, 200);
711
});

transforms/__testfixtures__/v4-deprecated-signatures/jsonp.output.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import express from "express";
22

33
const app = express();
44

5+
app.get("/json", function (req, res) {
6+
res.json();
7+
});
8+
59
app.get("/jsonp", function (req, res) {
610
res.status(200).jsonp({ user: "Username", isValid: true });
711
});

transforms/__testfixtures__/v4-deprecated-signatures/redirect.input.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ import { redirect } from "somelibrary";
33

44
const app = express();
55

6+
app.get("/", function (...arg) {
7+
const [, res] = arg
8+
res.redirect();
9+
});
10+
11+
app.get("/", function (...arg) {
12+
const [, res] = arg
13+
res.redirect("/other-page", 301);
14+
});
15+
16+
app.get("/", function (req, res) {
17+
res.redirect();
18+
});
19+
620
app.get("/", function (req, res) {
721
res.redirect("/other-page", 301);
822
});

transforms/__testfixtures__/v4-deprecated-signatures/redirect.output.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ import { redirect } from "somelibrary";
33

44
const app = express();
55

6+
app.get("/", function (...arg) {
7+
const [, res] = arg
8+
res.redirect();
9+
});
10+
11+
app.get("/", function (...arg) {
12+
const [, res] = arg
13+
res.redirect(301, "/other-page");
14+
});
15+
16+
app.get("/", function (req, res) {
17+
res.redirect();
18+
});
19+
620
app.get("/", function (req, res) {
721
res.redirect(301, "/other-page");
822
});

transforms/__testfixtures__/v4-deprecated-signatures/send-file.input.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const sharedSendFile = (res, next, fileName) => {
2222
})
2323
}
2424

25+
app.get('/file/:name', (req, res, next) => {
26+
res.sendfile()
27+
})
28+
29+
app.get('/file/:name', (req, res, next) => {
30+
res.sendfile("file.txt")
31+
})
32+
2533
app.get('/file/:name', (req, res, next) => {
2634
const fileName = req.params.name
2735

transforms/__testfixtures__/v4-deprecated-signatures/send-file.output.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const sharedSendFile = (res, next, fileName) => {
2222
})
2323
}
2424

25+
app.get('/file/:name', (req, res, next) => {
26+
res.sendFile()
27+
})
28+
29+
app.get('/file/:name', (req, res, next) => {
30+
res.sendFile("file.txt")
31+
})
32+
2533
app.get('/file/:name', (req, res, next) => {
2634
const fileName = req.params.name
2735

0 commit comments

Comments
 (0)