Skip to content

Commit

Permalink
Merge pull request #206 from CubingZA/update/server-packages
Browse files Browse the repository at this point in the history
Update/server packages
  • Loading branch information
AlphaSheep authored Dec 19, 2023
2 parents 2c3959b + 6934a51 commit 3196821
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 104 deletions.
2 changes: 1 addition & 1 deletion server/api/users/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function show(req, res, next) {
*/
export function destroy(req, res) {
let userId = sanitize(req.params.id);
return User.findByIdAndRemove(userId).exec()
return User.findByIdAndDelete(userId).exec()
.then(function(user) {
if(!user) {
return res.status(404).end();
Expand Down
10 changes: 5 additions & 5 deletions server/api/users/user.controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ describe ("User controller:", function() {

describe('when the user ID is found', function() {
beforeEach(async function() {
// mockingoose doesn't support findByIdAndRemove, so have to workaround
mockingoose(User).toReturn(mockUserData[0], 'findOneAndRemove');
User.findByIdAndRemove = jest.fn(User.findOneAndRemove);
// mockingoose doesn't support findByIdAndDelete, so have to workaround
mockingoose(User).toReturn(mockUserData[0], 'findOneAndDelete');
User.findByIdAndDelete = jest.fn(User.findOneAndDelete);
req.params = {_id: "0"}
await controller.destroy(req, res)
});
Expand All @@ -243,8 +243,8 @@ describe ("User controller:", function() {
expect(res.status).toHaveBeenCalledWith(204);
});

it("should call UserModel.findByIdAndRemove", async function() {
expect(User.findByIdAndRemove).toHaveBeenCalledWith(req.params.id);
it("should call UserModel.findByIdAndDelete", async function() {
expect(User.findByIdAndDelete).toHaveBeenCalledWith(req.params.id);
});
});

Expand Down
Loading

0 comments on commit 3196821

Please sign in to comment.