Skip to content

Commit cfc8e99

Browse files
committed
feat: add new test for increased coverage
Signed-off-by: Animesh Pathak <[email protected]>
1 parent 57bbb8b commit cfc8e99

File tree

7 files changed

+6221
-2941
lines changed

7 files changed

+6221
-2941
lines changed

Diff for: lib/middleware/body-parser.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ module.exports = (req, res, next) => {
7070
req.multiPartData = [];
7171
req.multiPartParams = [];
7272

73+
if (!parameters.boundary) {
74+
return next(new Error("Boundary required for multipart form-data"));
75+
}
76+
7377
// parse a file upload
7478
const dice = new Dicer({
7579
boundary: parameters.boundary,
@@ -113,7 +117,7 @@ module.exports = (req, res, next) => {
113117
dice.on("finish", () => {
114118
// createa a new simple object param
115119
req.multiPart = req.multiPartParams.map((param, index) => {
116-
// append value to pair
120+
117121
param.value = req.multiPartData[index];
118122

119123
switch (typeof req.multiPartSimple[param.name]) {

Diff for: lib/middleware/error-handler.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const debug = require("debug")("mockbin");
22

33
module.exports = (err, req, res, next) => {
4-
debug(err);
4+
debug(err);
55

6-
res.status(err.status || 500).view = "error";
6+
const status = err?.status || 500;
7+
res.status(status).view = "error";
78

8-
next();
9+
next();
910
};

0 commit comments

Comments
 (0)