-
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
1 parent
4c894a6
commit 0fd0a69
Showing
1 changed file
with
15 additions
and
3 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 |
---|---|---|
|
@@ -56,14 +56,26 @@ describe("User Routes", () => { | |
|
||
describe("GET /api/users/:id", () => { | ||
it("should get a specific user", async () => { | ||
const userId = "64e0c6963707b139178a6c46"; | ||
const expectedEmail = "[email protected]"; | ||
// Create a user first | ||
const newUser = { | ||
name: "Test User", | ||
email: "[email protected]", | ||
password: "password123", | ||
}; | ||
let createUserResponse = await request(app) | ||
.post("/api/users/register") | ||
.send(newUser); | ||
|
||
const userId = createUserResponse.body._id; | ||
|
||
// Now get the created user by ID | ||
const res = await request(app).get(`/api/users/${userId}`); | ||
|
||
expect(res.statusCode).toEqual(200); | ||
expect(res.body).toHaveProperty("email"); | ||
expect(res.body.email).toEqual(expectedEmail); | ||
expect(res.body.email).toEqual(newUser.email); | ||
|
||
await request(app).delete(`/api/users/${newUser.email}`); | ||
}); | ||
}); | ||
|
||
|