Nuxt/examples/with-feathers/test/app.test.js

37 lines
931 B
JavaScript
Raw Normal View History

2018-03-16 16:12:06 +00:00
import assert from 'assert'
import request from 'request'
import app from '../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-10-31 13:43:55 +00:00
})
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.strictEqual(res.statusCode, 404)
2017-10-31 13:43:55 +00:00
assert.ok(body.indexOf('This page could not be found.') !== -1)
done(err)
})
})
})
})