1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 const assert = require('assert');
\r
18 const rp = require('request-promise');
\r
19 const url = require('url');
\r
20 const app = require('../src/app');
\r
22 const port = app.get('port') || 3030;
\r
23 const getUrl = pathname => url.format({
\r
24 hostname: app.get('host') || 'localhost',
\r
30 describe('Feathers application tests', () => {
\r
31 before(function (done) {
\r
32 this.server = app.listen(port);
\r
33 this.server.once('listening', () => done());
\r
36 after(function (done) {
\r
37 this.server.close(done);
\r
40 it('starts and shows the index page', () => {
\r
41 return rp(getUrl()).then(body =>
\r
42 assert.ok(body.indexOf('<html>') !== -1)
\r
46 describe('404', function () {
\r
47 it('shows a 404 HTML page', () => {
\r
49 url: getUrl('path/to/nowhere'),
\r
51 'Accept': 'text/html'
\r
54 assert.strictEqual(res.statusCode, 404);
\r
55 assert.ok(res.error.indexOf('<html>') !== -1);
\r
59 it('shows a 404 JSON error without stack trace', () => {
\r
61 url: getUrl('path/to/nowhere'),
\r
64 assert.strictEqual(res.statusCode, 404);
\r
65 assert.strictEqual(res.error.code, 404);
\r
66 assert.strictEqual(res.error.message, 'Page not found');
\r
67 assert.strictEqual(res.error.name, 'NotFound');
\r