summaryrefslogtreecommitdiff
path: root/test/app.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/app.test.js')
-rw-r--r--test/app.test.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/app.test.js b/test/app.test.js
new file mode 100644
index 0000000..a16c396
--- /dev/null
+++ b/test/app.test.js
@@ -0,0 +1,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);
+ });
+ });
+ });
+});