2017-10-31 13:43:55 +00:00
|
|
|
'use strict'
|
2017-01-11 19:13:38 +00:00
|
|
|
|
2017-10-31 13:43:55 +00:00
|
|
|
const assert = require('assert')
|
|
|
|
const request = require('request')
|
|
|
|
const app = require('../src/app')
|
2017-01-11 19:13:38 +00:00
|
|
|
|
2017-10-31 13:43:55 +00:00
|
|
|
describe('Feathers application tests', function () {
|
|
|
|
before(function (done) {
|
|
|
|
this.server = app.listen(3030)
|
|
|
|
this.server.once('listening', () => done())
|
|
|
|
})
|
2017-01-11 19:13:38 +00:00
|
|
|
|
2017-10-31 13:43:55 +00:00
|
|
|
after(function (done) {
|
|
|
|
this.server.close(done)
|
|
|
|
})
|
2017-01-11 19:13:38 +00:00
|
|
|
|
2017-10-31 13:43:55 +00:00
|
|
|
it('starts and shows the index page', function (done) {
|
|
|
|
request('http://localhost:3030', function (err, res, body) {
|
|
|
|
assert.ok(body.indexOf('<h1>Welcome!</h1>') !== -1)
|
|
|
|
done(err)
|
|
|
|
})
|
|
|
|
})
|
2017-01-11 19:13:38 +00:00
|
|
|
|
2017-10-31 13:43:55 +00:00
|
|
|
describe('404', function () {
|
|
|
|
it('shows a 404 HTML page', function (done) {
|
2017-01-11 19:13:38 +00:00
|
|
|
request({
|
|
|
|
url: 'http://localhost:3030/path/to/nowhere',
|
|
|
|
headers: {
|
|
|
|
'Accept': 'text/html'
|
|
|
|
}
|
2017-10-31 13:43:55 +00:00
|
|
|
}, function (err, res, body) {
|
|
|
|
assert.equal(res.statusCode, 404)
|
|
|
|
assert.ok(body.indexOf('This page could not be found.') !== -1)
|
|
|
|
done(err)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|