Skip to content

Commit

Permalink
Add user meetings tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Piterson25 committed Apr 11, 2024
1 parent e012ae0 commit 25a0daa
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions backend/test/userMeetings.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { expect, test } from "vitest";
import { fetchData } from "./fetchData.js";

let userId: string = "";

const getFirstUser = async () => {
const response = await fetchData(`http://localhost:5000/users`, "GET", {});
userId = response.users[0].id;
};

await getFirstUser();

test("Get users meetings", async () => {
const response = await fetchData(
`http://localhost:5000/users/meetings/${userId}`,
"GET",
{},
);

const { status, meetings } = response;

expect(status).toBe("ok");
expect(meetings).toBeDefined();
expect(meetings.length).toBe(0);
});

test("Get users meetings without id", async () => {
const response = await fetchData(
`http://localhost:5000/users/meetings`,
"GET",
{},
);

const { status, errors } = response;

expect(status).toBe("error");
expect(errors).toBeDefined();
expect(errors.id).toBe("not found");
});

test("Update meeting", async () => {
const response = await fetchData(
`http://localhost:5000/users/meetings/0`,
"PUT",
{
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);

const { status } = response;

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

0 comments on commit 25a0daa

Please sign in to comment.