Skip to content

Commit

Permalink
Fixed broken unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nitro404 committed Jun 2, 2018
1 parent b3ec111 commit e4f2fd5
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions test/test.js
Expand Up @@ -109,7 +109,7 @@ router.get("/:id", function(req, res, next) {
var albumId = utilities.parseInteger(req.params.id);

if(!Number.isInteger(albumId)) {
return status(400).json({ message: "Empty or invalid album id." });
return res.status(400).json({ message: "Empty or invalid album id." });
}

return res.json(albums.find(function(album) {
Expand All @@ -124,7 +124,7 @@ router.post("/", function(req, res, next) {
formattedAlbum = utilities.formatValue(req.body, albumFormat, { throwErrors: true, verbose: false });
}
catch(error) {
return status(400).json(error);
return res.status(400).json({ message: error.message });
}

albums.push(formattedAlbum);
Expand All @@ -136,7 +136,7 @@ router.put("/:id", function(req, res, next) {
var albumId = utilities.parseInteger(req.params.id);

if(!Number.isInteger(albumId)) {
return status(400).json({ message: "Empty or invalid album id." });
return res.status(400).json({ message: "Empty or invalid album id." });
}

var albumIndex = -1;
Expand All @@ -149,15 +149,17 @@ router.put("/:id", function(req, res, next) {
}

if(albumIndex === -1) {
return status(404).json({ message: "Album with id " + albumId + "not found." });
return res.status(404).json({ message: "Album with id " + albumId + "not found." });
}

var formattedAlbum = null;

try {
formattedAlbum = utilities.formatValue(req.body, albumFormat, { throwErrors: true, verbose: false });
formattedAlbum.id = albumId;
}
catch(error) {
return status(400).json(error);
return res.status(400).json({ message: error.message });
}

albums[albumIndex] = formattedAlbum;
Expand All @@ -169,7 +171,7 @@ router.patch("/:id", function(req, res, next) {
var albumId = utilities.parseInteger(req.params.id);

if(!Number.isInteger(albumId)) {
return status(400).json({ message: "Empty or invalid album id." });
return res.status(400).json({ message: "Empty or invalid album id." });
}

var albumIndex = -1;
Expand All @@ -182,15 +184,17 @@ router.patch("/:id", function(req, res, next) {
}

if(albumIndex === -1) {
return status(404).json({ message: "Album with id " + albumId + "not found." });
return res.status(404).json({ message: "Album with id " + albumId + "not found." });
}

var formattedAlbum = null;

try {
formattedAlbum = utilities.formatValue(req.body, patchAlbumFormat, { throwErrors: true, verbose: false });
formattedAlbum.id = albumId;
}
catch(error) {
return status(400).json(error);
return res.status(400).json({ message: error.message });
}

utilities.merge(albums[albumIndex], formattedAlbum, false);
Expand All @@ -202,7 +206,7 @@ router.delete("/:id", function(req, res, next) {
var albumId = utilities.parseInteger(req.params.id);

if(!Number.isInteger(albumId)) {
return status(400).json({ message: "Empty or invalid album id." });
return res.status(400).json({ message: "Empty or invalid album id." });
}

var count = 0;
Expand Down

0 comments on commit e4f2fd5

Please sign in to comment.