-
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
32346ef
commit 2aada44
Showing
5 changed files
with
34 additions
and
16 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 |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import { expect, test } from "vitest"; | ||
import { fetchData } from "../src/misc/fetchData.js"; | ||
import User from "../src/models/User.js"; | ||
|
||
let userId1: string = ""; | ||
let userId2: string = ""; | ||
|
||
const getUsers = async () => { | ||
const response = await fetchData(`http://localhost:5000/users`, "GET", {}); | ||
userId1 = response.users[0].id; | ||
userId2 = response.users[1].id; | ||
userId1 = response.users.find( | ||
(user: User) => user.mail === "[email protected]", | ||
).id; | ||
userId2 = response.users.find( | ||
(user: User) => user.mail === "[email protected]", | ||
).id; | ||
}; | ||
|
||
await getUsers(); | ||
|
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 |
---|---|---|
|
@@ -9,8 +9,12 @@ let userId2: string = ""; | |
|
||
const getUsers = async () => { | ||
const response = await fetchData(`http://localhost:5000/users`, "GET", {}); | ||
userId = response.users[0].id; | ||
userId2 = response.users[1].id; | ||
userId = response.users.find( | ||
(user: User) => user.mail === "[email protected]", | ||
).id; | ||
userId2 = response.users.find( | ||
(user: User) => user.mail === "[email protected]", | ||
).id; | ||
}; | ||
|
||
await getUsers(); | ||
|
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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { expect, test } from "vitest"; | ||
import { fetchData } from "../src/misc/fetchData.js"; | ||
import User from "../src/models/User.js"; | ||
|
||
let userId: number; | ||
let page: number = 3; | ||
let maxUsers: number = 5; | ||
|
||
const getFirstUser = async () => { | ||
const response = await fetchData(`http://localhost:5000/users`, "GET", {}); | ||
userId = response.users[0].id; | ||
userId = response.users.find( | ||
(user: User) => user.mail === "[email protected]", | ||
).id; | ||
}; | ||
|
||
await getFirstUser(); | ||
|
@@ -22,9 +25,9 @@ test("Get friend suggestions", async () => { | |
const { status, pageCount, friendSuggestions } = response; | ||
|
||
expect(status).toBe("ok"); | ||
expect(pageCount).toBe(4); | ||
expect(pageCount).toBe(3); | ||
expect(friendSuggestions).toBeDefined(); | ||
expect(friendSuggestions.length).toBe(5); | ||
expect(friendSuggestions.length).toBe(3); | ||
}); | ||
|
||
test("Get friend suggestions with incorrect ID", async () => { | ||
|
@@ -108,7 +111,7 @@ test("First user", async () => { | |
const { status, pageCount, friendSuggestions } = response; | ||
|
||
expect(status).toBe("ok"); | ||
expect(pageCount).toBe(17); | ||
expect(pageCount).toBe(13); | ||
expect(friendSuggestions).toBeDefined(); | ||
expect(friendSuggestions.length).toBe(1); | ||
}); | ||
|
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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { expect, test } from "vitest"; | ||
import { fetchData } from "../src/misc/fetchData.js"; | ||
import User from "../src/models/User.js"; | ||
|
||
let page: number = 1; | ||
let maxUsers: number = 10; | ||
let userId: string = ""; | ||
|
||
const getFirstUser = async () => { | ||
const response = await fetchData(`http://localhost:5000/users`, "GET", {}); | ||
userId = response.users[0].id; | ||
userId = response.users.find( | ||
(user: User) => user.mail === "[email protected]", | ||
).id; | ||
}; | ||
|
||
await getFirstUser(); | ||
|
@@ -23,7 +26,7 @@ test("Get friends", async () => { | |
|
||
expect(status).toBe("ok"); | ||
expect(pageCount).toBe(1); | ||
expect(friends.length).toBe(6); | ||
expect(friends.length).toBe(9); | ||
}); | ||
|
||
test("Get friends with incorrect ID", async () => { | ||
|
@@ -118,12 +121,12 @@ test("First user", async () => { | |
const { status, pageCount, friends } = response; | ||
|
||
expect(status).toBe("ok"); | ||
expect(pageCount).toBe(6); | ||
expect(pageCount).toBe(9); | ||
expect(friends.length).toBe(1); | ||
expect(friends[0].country).toBe("PL"); | ||
expect(friends[0].mail).toBe("[email protected]"); | ||
expect(friends[0].first_name).toBe("Abby"); | ||
expect(friends[0].last_name).toBe("Godney"); | ||
expect(friends[0].country).toBe("CN"); | ||
expect(friends[0].mail).toBe("[email protected]"); | ||
expect(friends[0].first_name).toBe("Trever"); | ||
expect(friends[0].last_name).toBe("Shillito"); | ||
}); | ||
|
||
test("maxUsers equals 0", async () => { | ||
|
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { expect, test } from "vitest"; | ||
import { fetchData } from "../src/misc/fetchData.js"; | ||
import User from "../src/models/User.js"; | ||
|
||
let userId: string = ""; | ||
|
||
const getFirstUser = async () => { | ||
const response = await fetchData(`http://localhost:5000/users`, "GET", {}); | ||
userId = response.users[0].id; | ||
userId = response.users.find( | ||
(user: User) => user.mail === "[email protected]", | ||
).id; | ||
}; | ||
|
||
await getFirstUser(); | ||
|