Skip to content

Commit 285e93e

Browse files
committed
More assertions in tests.
1 parent 305ce4f commit 285e93e

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

test/v1-all.test.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
const app = require("../app")
33
const request = require("supertest")
4-
const express = require("express")
54

65
beforeAll((done) => {
76
app.on("ready", () => {
@@ -161,8 +160,8 @@ test("It should return all past launches from LC-4E", () => {
161160

162161
test("It should return no launches from made up launchpad", () => {
163162
return request(app).get("/v1/launches?site=vafb_slc_5e").then(response => {
164-
expect(response.statusCode).toBe(404)
165-
expect(response.text).toContain("No results found")
163+
expect(response.statusCode).toBe(200)
164+
expect(response.body).toEqual([])
166165
})
167166
})
168167

@@ -175,21 +174,22 @@ test("It should return all 2012 launches", () => {
175174

176175
test("It should return no 2005 launches", () => {
177176
return request(app).get("/v1/launches?year=2005").then(response => {
178-
expect(response.statusCode).toBe(404)
179-
expect(response.text).toContain("No results found")
177+
expect(response.statusCode).toBe(200)
178+
expect(response.body).toEqual([])
180179
})
181180
})
182181

183182
test("It should return past launches in timeframe", () => {
184183
return request(app).get("/v1/launches?start=2011-01-20&final=2017-05-25").then(response => {
185184
expect(response.statusCode).toBe(200)
185+
expect(response.body).not.toHaveLength(0)
186186
})
187187
})
188188

189189
test("It should return no past launches in timeframe", () => {
190190
return request(app).get("/v1/launches?start=2005-01-20&final=2005-05-25").then(response => {
191-
expect(response.statusCode).toBe(404)
192-
expect(response.text).toContain("No results found")
191+
expect(response.statusCode).toBe(200)
192+
expect(response.body).toEqual([])
193193
})
194194
})
195195

@@ -202,8 +202,8 @@ test("It should return all launches with core B1021", () => {
202202

203203
test("It should return no launches with core A1021", () => {
204204
return request(app).get("/v1/launches/cores/A1021").then(response => {
205-
expect(response.statusCode).toBe(404)
206-
expect(response.text).toContain("No results found")
205+
expect(response.statusCode).toBe(200)
206+
expect(response.body).toEqual([])
207207
})
208208
})
209209

@@ -216,8 +216,8 @@ test("It should return all launches with cap C106", () => {
216216

217217
test("It should return no launches with cap C403", () => {
218218
return request(app).get("/v1/launches/caps/C403").then(response => {
219-
expect(response.statusCode).toBe(404)
220-
expect(response.text).toContain("No results found")
219+
expect(response.statusCode).toBe(200)
220+
expect(response.body).toEqual([])
221221
})
222222
})
223223

@@ -242,32 +242,35 @@ test("It should return all past RTLS launches", () => {
242242
test("It should return all upcoming launches", () => {
243243
return request(app).get("/v1/launches/upcoming").then(response => {
244244
expect(response.statusCode).toBe(200)
245+
expect(response.body).not.toHaveLength(0)
245246
})
246247
})
247248

248249
test("It should return all upcoming launches in 2017", () => {
249250
return request(app).get("/v1/launches/upcoming?year=2017").then(response => {
250251
expect(response.statusCode).toBe(200)
252+
expect(response.body).not.toHaveLength(0)
251253
})
252254
})
253255

254256
test("It should return no upcoming launches in 2016", () => {
255257
return request(app).get("/v1/launches/upcoming?year=2016").then(response => {
256-
expect(response.statusCode).toBe(404)
257-
expect(response.text).toContain("No results found")
258+
expect(response.statusCode).toBe(200)
259+
expect(response.body).toEqual([])
258260
})
259261
})
260262

261263
test("It should return all launches in the timeframe", () => {
262264
return request(app).get("/v1/launches/upcoming?start=2011-01-20&final=2055-05-25").then(response => {
263265
expect(response.statusCode).toBe(200)
266+
expect(response.body).not.toHaveLength(0)
264267
})
265268
})
266269

267270
test("It should return no launches in the timeframe", () => {
268271
return request(app).get("/v1/launches/upcoming?start=2011-01-20&final=2016-05-25").then(response => {
269-
expect(response.statusCode).toBe(404)
270-
expect(response.text).toContain("No results found")
272+
expect(response.statusCode).toBe(200)
273+
expect(response.body).toEqual([])
271274
})
272275
})
273276

0 commit comments

Comments
 (0)