This repository was archived by the owner on Jul 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.js
More file actions
43 lines (37 loc) · 1.3 KB
/
test.js
File metadata and controls
43 lines (37 loc) · 1.3 KB
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
39
40
41
42
43
var request = require("supertest");
var server = require('./server');
app = server();
var test = request(app);
test.get("/")
.expect('Content-Type', /json/)
.expect(200)
.end(function(err, res){
if (err) throw err;
if (!res.body.description) throw "Needs a description";
if (!res.body.data) throw "Needs some data";
if (res.body.data.foods.indexOf("fruits") === -1) throw "Needs data in that data";
if (!res.body.data["words/literature"].length) throw "Should handle sub-nesting";
});
test.get("/bork")
.expect('Content-Type', /json/)
.expect(404)
.end(function(err, res){
if (err) throw err;
if (res.body.error !== "404 Not Found") throw "Needs an error description";
});
test.get("/foods/fruits")
.expect('Content-Type', /json/)
.expect(200)
.end(function(err, res){
if (err) throw err;
if (!res.body.data) throw "Needs some data";
if (res.body.data.fruits.indexOf("apple") === -1) throw "Needs an apple a day in that data";
});
test.get("/words/literature/shakespeare_words")
.expect('Content-Type', /json/)
.expect(200)
.end(function(err, res){
if (err) throw err;
if (!res.body.data) throw "Needs some data";
if (res.body.data.words.indexOf("abstemious") === -1) throw "not self-indulgent, especially when eating and drinking.";
});