Skip to content

Commit

Permalink
test19
Browse files Browse the repository at this point in the history
  • Loading branch information
brok3turtl3 committed Nov 29, 2023
1 parent 4c894a6 commit 0fd0a69
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions __tests__/userRoutes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
});

Expand Down

0 comments on commit 0fd0a69

Please sign in to comment.