File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments