-
Notifications
You must be signed in to change notification settings - Fork 2
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
e012ae0
commit 25a0daa
Showing
1 changed file
with
56 additions
and
0 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 |
---|---|---|
@@ -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"); | ||
}); |