-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.test.js
38 lines (35 loc) · 1.16 KB
/
app.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const supertest = require("supertest");
const app = require("./app");
test("Tests whether /tickets returns the response which is an array", async () => {
await supertest(app)
.get("/tickets")
.expect(200)
.then((response) => {
var tickets = response.body.tickets;
// Check type and length
expect(Array.isArray(tickets)).toBeTruthy();
});
});
test("Tests whether /tickets returns the response where key=tags is an array of length 3", async () => {
await supertest(app)
.get("/tickets")
.expect(200)
.then((response) => {
var tickets = response.body.tickets;
var i;
for (i = 0; i < tickets.length; i++) {
expect(Array.isArray(tickets[0].tags)).toBeTruthy();
expect(tickets[0].tags.length).toBe(3);
}
});
});
// This test takes into consideration that # of tickets returned will be greater than 75
test("Tests whether the response from /tickets is paginated if count of tickets is greater than 25", async () => {
await supertest(app)
.get("/tickets")
.expect(200)
.then((response) => {
var tickets = response.body.tickets;
expect(tickets.length / 25).toBe(4);
});
});