Skip to content

Commit

Permalink
Added test for logoutRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
cindyliang01 committed Nov 30, 2023
1 parent ba0ec02 commit 7f7cfc6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 0 additions & 4 deletions back-end/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ UserSchema.methods.toAuthJSON = function () {

UserSchema.methods.resetPassword = function (newPassword) {
this.password = newPassword;
// return {
// username: this.username,
// token: this.generateJWT(),
// };
};

const User = mongoose.model("User", UserSchema);
Expand Down
2 changes: 1 addition & 1 deletion back-end/routes/logoutRoute.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const express = require("express");
const router = express.Router();

router.get("/logout", function (req, res, next) {
router.get("/", function (req, res, next) {
res.json({
success: true,
message:
Expand Down
21 changes: 21 additions & 0 deletions back-end/test/logoutRoute.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const chai = require("chai");
const chaiHttp = require("chai-http");
const server = require("../app");
const expect = chai.expect;

chai.use(chaiHttp);

describe(" GET Endpoint for logout", () => {
describe("/GET /logout", () => {
it("it should return a 200 status code", (done) => {
chai
.request(server)
.get("/logout")
.end((err, res) => {
expect(res).to.have.status(200);
expect(res.body).to.be.a("object");
done();
});
});
});
});

0 comments on commit 7f7cfc6

Please sign in to comment.