Skip to content

Commit

Permalink
Add check friend requests test
Browse files Browse the repository at this point in the history
  • Loading branch information
Piterson25 committed Apr 5, 2024
1 parent 5e3c07e commit 962da73
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions backend/test/userFriendRequests.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect, test } from "vitest";

let userId: number;
let page: number = 1;
let maxUsers: number = 1;

test("Search user", async () => {
const response = await fetch(
"http://localhost:5000/users/search?q=a&page=1&maxUsers=10",
);

const responseData = await response.json();
const users = responseData.users;
const status = responseData.status;

expect(status).toBe("ok");

userId = users[0].id;
});

test("Check current requests", async () => {
const response = await fetch(
`http://localhost:5000/users/${userId}/friend-requests?page=${page}&maxUsers=${maxUsers}`,
);

const responseData = await response.json();
const friendRequests = responseData.friendRequests;
const status = responseData.status;

expect(status).toBe("ok");

expect(friendRequests.length).toBe(0);
});

0 comments on commit 962da73

Please sign in to comment.