-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,10 @@ const app = require("../app"); | |
const User = require("../models/users"); | ||
// const mongoose = require("mongoose"); | ||
|
||
// beforeEach(async () => { | ||
// global.console = { log: jest.fn() }; | ||
// }); | ||
beforeEach(async () => { | ||
await User.deleteMany({}); | ||
global.console = { log: jest.fn() }; | ||
}); | ||
|
||
test("it can register new user", async () => { | ||
const response = await request(app).post("/register").send({ | ||
|
@@ -18,16 +19,13 @@ test("it can register new user", async () => { | |
}); | ||
|
||
test("it can login user", async () => { | ||
let existingUser = await User.findOne({ email: "[email protected]" }); | ||
if (!existingUser) { | ||
existingUser = await User({ | ||
firstname: "John", | ||
lastname: "Doe", | ||
email: "[email protected]", | ||
password: "$2a$10$Qsu.gk.u76oq9Gx4uFq5F.b7JSsrx1/Vh8vROou/9ilZAnNoKniGW", // secret hashed | ||
}).save(); | ||
} | ||
console.log("existingUser", existingUser); | ||
await User({ | ||
firstname: "John", | ||
lastname: "Doe", | ||
email: "[email protected]", | ||
password: "$2a$10$Qsu.gk.u76oq9Gx4uFq5F.b7JSsrx1/Vh8vROou/9ilZAnNoKniGW", // secret hashed | ||
}).save(); | ||
|
||
const response = await request(app).post("/login").send({ | ||
email: "[email protected]", | ||
password: "secret", | ||
|