-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.test.js
51 lines (45 loc) · 1.32 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
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
const assert = require('assert');
const request = require('request');
const app = require('../src/app');
describe('Feathers application tests', function() {
before(function(done) {
this.server = app.listen(3030);
this.server.once('listening', () => done());
});
after(function(done) {
this.server.close(done);
});
it('starts and shows the index page', function(done) {
request('http://localhost:3030', function(err, res, body) {
assert.ok(body.indexOf('<html>') !== -1);
done(err);
});
});
describe('404', function() {
it('shows a 404 HTML page', function(done) {
request({
url: 'http://localhost:3030/path/to/nowhere',
headers: {
'Accept': 'text/html'
}
}, function(err, res, body) {
assert.equal(res.statusCode, 404);
assert.ok(body.indexOf('<html>') !== -1);
done(err);
});
});
it('shows a 404 JSON error without stack trace', function(done) {
request({
url: 'http://localhost:3030/path/to/nowhere',
json: true
}, function(err, res, body) {
assert.equal(res.statusCode, 404);
assert.equal(body.code, 404);
assert.equal(body.message, 'Page not found');
assert.equal(body.name, 'NotFound');
done(err);
});
});
});
});