1 const assert = require('assert');
\r
2 const rp = require('request-promise');
\r
3 const url = require('url');
\r
4 const app = require('../src/app');
\r
6 const port = app.get('port') || 3030;
\r
7 const getUrl = pathname => url.format({
\r
8 hostname: app.get('host') || 'localhost',
\r
14 describe('Feathers application tests', () => {
\r
15 before(function (done) {
\r
16 this.server = app.listen(port);
\r
17 this.server.once('listening', () => done());
\r
20 after(function (done) {
\r
21 this.server.close(done);
\r
24 it('starts and shows the index page', () => {
\r
25 return rp(getUrl()).then(body =>
\r
26 assert.ok(body.indexOf('<html>') !== -1)
\r
30 describe('404', function () {
\r
31 it('shows a 404 HTML page', () => {
\r
33 url: getUrl('path/to/nowhere'),
\r
35 'Accept': 'text/html'
\r
38 assert.strictEqual(res.statusCode, 404);
\r
39 assert.ok(res.error.indexOf('<html>') !== -1);
\r
43 it('shows a 404 JSON error without stack trace', () => {
\r
45 url: getUrl('path/to/nowhere'),
\r
48 assert.strictEqual(res.statusCode, 404);
\r
49 assert.strictEqual(res.error.code, 404);
\r
50 assert.strictEqual(res.error.message, 'Page not found');
\r
51 assert.strictEqual(res.error.name, 'NotFound');
\r