1- // SpaceX API Tests
21
32const app = require ( "../app" )
43const request = require ( "supertest" )
@@ -9,30 +8,42 @@ beforeAll((done) => {
98 } )
109} )
1110
12- // 404 Test
11+ //------------------------------------------------------------
12+ // 404 Page
13+ //------------------------------------------------------------
14+
1315test ( "It should return 404 page" , ( ) => {
1416 return request ( app ) . get ( "/v2" ) . then ( response => {
1517 expect ( response . statusCode ) . toBe ( 404 )
1618 } )
1719} )
1820
19- // Home Tests
21+ //------------------------------------------------------------
22+ // Home Page
23+ //------------------------------------------------------------
24+
2025test ( "It should return home info" , ( ) => {
2126 return request ( app ) . get ( "/v1" ) . then ( response => {
2227 expect ( response . statusCode ) . toBe ( 200 )
2328 expect ( response . text ) . toContain ( "SpaceX-API" )
2429 } )
2530} )
2631
27- // Info Tests
32+ //------------------------------------------------------------
33+ // Company Info
34+ //------------------------------------------------------------
35+
2836test ( "It should return company info" , ( ) => {
2937 return request ( app ) . get ( "/v1/info" ) . then ( response => {
3038 expect ( response . statusCode ) . toBe ( 200 )
3139 expect ( response . text ) . toContain ( "Elon Musk" )
3240 } )
3341} )
3442
35- // Vehicle Tests
43+ //------------------------------------------------------------
44+ // Vehicles
45+ //------------------------------------------------------------
46+
3647test ( "It should return all vehicle info" , ( ) => {
3748 return request ( app ) . get ( "/v1/vehicles" ) . then ( response => {
3849 expect ( response . statusCode ) . toBe ( 200 )
@@ -71,7 +82,10 @@ test("It should return Dragon info", () => {
7182 } )
7283} )
7384
74- // Launchpad Tests
85+ //------------------------------------------------------------
86+ // Launchpads
87+ //------------------------------------------------------------
88+
7589test ( "It should return all launchpads" , ( ) => {
7690 return request ( app ) . get ( "/v1/launchpads" ) . then ( response => {
7791 expect ( response . statusCode ) . toBe ( 200 )
@@ -93,7 +107,10 @@ test("It should return no launchpads found info", () => {
93107 } )
94108} )
95109
96- // Past Launches Tests
110+ //------------------------------------------------------------
111+ // Past Launches
112+ //------------------------------------------------------------
113+
97114test ( "It should return all past launches" , ( ) => {
98115 return request ( app ) . get ( "/v1/launches" ) . then ( response => {
99116 expect ( response . statusCode ) . toBe ( 200 )
@@ -163,7 +180,10 @@ test("It should return no launches with cap C403", () => {
163180 } )
164181} )
165182
166- // Upcoming Launch Tests
183+ //------------------------------------------------------------
184+ // Upcoming Launches
185+ //------------------------------------------------------------
186+
167187test ( "It should return all upcoming launches" , ( ) => {
168188 return request ( app ) . get ( "/v1/launches/upcoming" ) . then ( response => {
169189 expect ( response . statusCode ) . toBe ( 200 )
@@ -196,7 +216,10 @@ test("It should return no launches in the timeframe", () => {
196216 } )
197217} )
198218
199- // Parts Tests
219+ //------------------------------------------------------------
220+ // Parts
221+ //------------------------------------------------------------
222+
200223test ( "It should return all capsule info" , ( ) => {
201224 return request ( app ) . get ( "/v1/parts/caps" ) . then ( response => {
202225 expect ( response . statusCode ) . toBe ( 200 )
0 commit comments