Skip to content

Commit 4b5075f

Browse files
committed
refined comments in test files
1 parent 4bfe85e commit 4b5075f

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ notifications:
1010
on_failure: always
1111
after_success:
1212
- ./scripts/docker_build.sh
13-

app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
const express = require("express")
23
const morgan = require("morgan")
34
const cors = require("cors")
@@ -8,7 +9,6 @@ const MongoClient = require("mongodb")
89
const Path = require("path")
910
const app = express()
1011

11-
// Define route paths
1212
const home = require("./routes/v1-home")
1313
const info = require("./routes/v1-info")
1414
const vehicles = require("./routes/v1-vehicles")
@@ -17,13 +17,11 @@ const launches = require("./routes/v1-launches")
1717
const upcoming = require("./routes/v1-upcoming")
1818
const parts = require("./routes/v1-parts")
1919

20-
// Enable middleware
2120
app.use(compression())
2221
app.use(helmet())
2322
app.use(morgan("common"))
2423
app.use(cors())
2524

26-
// Routes
2725
app.use("/v1", home)
2826
app.use("/v1/info", info)
2927
app.use("/v1/vehicles", vehicles)
@@ -37,7 +35,6 @@ app.use((req, res) => {
3735
res.status(404).sendFile(Path.join(__dirname + "/pages/404.html"))
3836
})
3937

40-
// Create DB connection & start server
4138
MongoClient.connect(config.url, (err, database) => {
4239
if (err) return console.log(err)
4340
global.db = database

config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"test" : "success",
32
"url" : "mongodb://public:[email protected]:27017, spacex-api-shard-00-01-rzdz4.mongodb.net:27017,spacex-api-shard-00-02-rzdz4.mongodb.net:27017/spacex-api?ssl=true&replicaSet=spacex-api-shard-0&authSource=admin"
43
}

test/v1-all.test.js

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// SpaceX API Tests
21

32
const app = require("../app")
43
const request = require("supertest")
@@ -9,30 +8,42 @@ beforeAll((done) => {
98
})
109
})
1110

12-
// 404 Test
11+
//------------------------------------------------------------
12+
// 404 Page
13+
//------------------------------------------------------------
14+
1315
test("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+
2025
test("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+
2836
test("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+
3647
test("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+
7589
test("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+
97114
test("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+
167187
test("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+
200223
test("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

Comments
 (0)