Skip to content

Commit 2ccd435

Browse files
committed
Add live tests
1 parent 9ff5d6d commit 2ccd435

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/live/user.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { expect, test, describe } from "vitest";
2+
import { createJwt } from "./utils.js";
3+
import { getBaseEndpoint } from "./utils.js";
4+
5+
const baseEndpoint = getBaseEndpoint();
6+
7+
describe("User info live tests", async () => {
8+
const token = await createJwt();
9+
test(
10+
"Test that invalid emails are rejected",
11+
{ timeout: 10000 },
12+
async () => {
13+
const response = await fetch(
14+
`${baseEndpoint}/api/v1/users/batchResolveInfo`,
15+
{
16+
method: "POST",
17+
headers: {
18+
"Content-Type": "application/json",
19+
},
20+
body: JSON.stringify({
21+
emails: ["invalid"],
22+
}),
23+
},
24+
);
25+
expect(response.status).toBe(400);
26+
},
27+
);
28+
test("Test that valid emails are resolved", { timeout: 10000 }, async () => {
29+
const response = await fetch(
30+
`${baseEndpoint}/api/v1/users/batchResolveInfo`,
31+
{
32+
method: "POST",
33+
headers: {
34+
"Content-Type": "application/json",
35+
},
36+
body: JSON.stringify({
37+
emails: ["testinguser@illinois.edu"],
38+
}),
39+
},
40+
);
41+
expect(response.status).toBe(200);
42+
const responseJson = (await response.json()) as string[];
43+
expect(responseJson).toEqual({
44+
"testinguser@illinois.edu": {
45+
firstName: "Testing",
46+
lastName: "User",
47+
},
48+
});
49+
});
50+
});

0 commit comments

Comments
 (0)