-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspec.js
More file actions
34 lines (29 loc) · 830 Bytes
/
spec.js
File metadata and controls
34 lines (29 loc) · 830 Bytes
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
let should = require('chai').should()
,http = require('http')
,request = require('supertest')
var app = require("./index.js")
// define server base URL
var BASE_URL = "http://localhost:8080"
// run API test
describe("API Test with SuperTest", function(){
it("GET / should return 'Hello World!'", function(done) {
request(app)
.get('/api')
.expect(200,"Hello World!")
.expect('Content-Type', 'text/html; charset=utf-8')
.expect('X-Powered-By', 'Express')
.end( function(err, res){
done();
})
});
it("GET /test should return 404", function(done){
request(app)
.get('/test')
.expect(404)
.end(function(err, res){
if (err)
return done(err) // if response is 500 or 404 & err, test case will fail
done()
});
});
})