File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ import { expect , test } from "vitest" ;
2+
3+ const baseEndpoint = `https://core.aws.qa.acmuiuc.org` ;
4+
5+ test ( "Get OpenAPI JSON" , async ( ) => {
6+ const response = await fetch ( `${ baseEndpoint } /api/documentation/json` ) ;
7+ expect ( response . status ) . toBe ( 200 ) ;
8+
9+ const responseDataJson = await response . json ( ) ;
10+ expect ( responseDataJson ) . toHaveProperty ( "openapi" ) ;
11+ expect ( responseDataJson [ "openapi" ] ) . toEqual ( "3.0.3" ) ;
12+ } ) ;
13+
14+ test ( "Get OpenAPI UI" , async ( ) => {
15+ const response = await fetch ( `${ baseEndpoint } /api/documentation` ) ;
16+ expect ( response . status ) . toBe ( 200 ) ;
17+ const contentType = response . headers . get ( "content-type" ) ;
18+ expect ( contentType ) . toContain ( "text/html" ) ;
19+ } ) ;
Original file line number Diff line number Diff line change 1+ import { afterAll , expect , test } from "vitest" ;
2+ import init from "../../src/api/index.js" ;
3+
4+ const app = await init ( ) ;
5+ test ( "Test getting OpenAPI JSON" , async ( ) => {
6+ const response = await app . inject ( {
7+ method : "GET" ,
8+ url : "/api/documentation/json" ,
9+ } ) ;
10+ expect ( response . statusCode ) . toBe ( 200 ) ;
11+ const responseDataJson = await response . json ( ) ;
12+ expect ( responseDataJson ) . toHaveProperty ( "openapi" ) ;
13+ expect ( responseDataJson [ "openapi" ] ) . toEqual ( "3.0.3" ) ;
14+ } ) ;
15+ afterAll ( async ( ) => {
16+ await app . close ( ) ;
17+ } ) ;
18+
19+ test ( "Test getting OpenAPI UI" , async ( ) => {
20+ const response = await app . inject ( {
21+ method : "GET" ,
22+ url : "/api/documentation" ,
23+ } ) ;
24+ expect ( response . statusCode ) . toBe ( 200 ) ;
25+ const contentType = response . headers [ "content-type" ] ;
26+ expect ( contentType ) . toContain ( "text/html" ) ;
27+ } ) ;
28+ afterAll ( async ( ) => {
29+ await app . close ( ) ;
30+ } ) ;
You can’t perform that action at this time.
0 commit comments