Skip to content

Commit

Permalink
Añadiendo coverage a gateway service
Browse files Browse the repository at this point in the history
  • Loading branch information
iyanfdezz committed Apr 7, 2024
1 parent 36e4e5b commit 09d8502
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions gatewayservice/gateway-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,44 @@ describe("Gateway Service", () => {
expect(response.statusCode).toBe(200);
expect(response.body).toEqual({ saved: true });
});

// Prueba para la ruta /friends
it("should forward friends request to user service", async () => {
axios.get.mockResolvedValueOnce({ data: { friends: ["friend1", "friend2"] } });

const response = await request(app).get("/friends").query({ userId: "testuser" });

expect(response.statusCode).toBe(200);
expect(response.body).toEqual({ friends: ["friend1", "friend2"] });
});

// Prueba para la ruta /users/search
it("should forward search users request to user service", async () => {
axios.get.mockResolvedValueOnce({ data: { users: ["user1", "user2"] } });

const response = await request(app).get("/users/search").query({ query: "test" });

expect(response.statusCode).toBe(200);
expect(response.body).toEqual({ users: ["user1", "user2"] });
});

// Prueba para la ruta /users/add-friend
it("should forward add friend request to user service", async () => {
axios.post.mockResolvedValueOnce({ data: { success: true } });

const response = await request(app).post("/users/add-friend").send({ userId: "user1", friendId: "user2" });

expect(response.statusCode).toBe(200);
expect(response.body).toEqual({ success: true });
});

// Prueba para la ruta /users/remove-friend
it("should forward remove friend request to user service", async () => {
axios.post.mockResolvedValueOnce({ data: { success: true } });

const response = await request(app).post("/users/remove-friend").send({ userId: "user1", friendId: "user2" });

expect(response.statusCode).toBe(200);
expect(response.body).toEqual({ success: true });
});
});

0 comments on commit 09d8502

Please sign in to comment.