Split out 404 tests

This commit is contained in:
Jake Howard 2017-02-27 10:02:30 +00:00
parent dbce552acb
commit 630063f012
3 changed files with 21 additions and 16 deletions

View file

@ -11,7 +11,7 @@
"prepublish": "typings install && npm run build", "prepublish": "typings install && npm run build",
"build": "tsc", "build": "tsc",
"test": "npm run build && npm run mocha && nsp check", "test": "npm run build && npm run mocha && nsp check",
"mocha": "mocha --compilers ts:ts-node/register --require scripts/test-helper.js tests/**.test.ts", "mocha": "mocha --compilers ts:ts-node/register --require scripts/test-helper.js --recursive --bail tests/**/*.test.ts tests/*.test.ts",
"lint": "tslint src/**/*.ts" "lint": "tslint src/**/*.ts"
}, },
"engines": { "engines": {

View file

@ -0,0 +1,20 @@
import { expect } from 'chai';
import { runServer } from '../helpers';
describe('404 Middleware', function () {
it('Should respond with 404 on bad path', function (done) {
runServer({
allowed_ips: [],
basicAuth: [],
dirList: false,
serveDir: 'site/',
opbeat: false,
open: false
}, '/foo/bar', function (response : any) {
expect(response.ok).to.be.false;
expect(response.status).to.equal(404);
expect(response.text()).to.eventually.include('Cannot GET').notify(done);
});
});
});

View file

@ -24,21 +24,6 @@ describe('Server', function () {
}); });
}); });
it('Should respond with 404 on bad path', function (done) {
runServer({
allowed_ips: [],
basicAuth: [],
dirList: false,
serveDir: 'site/',
opbeat: false,
open: false
}, '/foo/bar', function (response : any) {
expect(response.ok).to.be.false;
expect(response.status).to.equal(404);
expect(response.text()).to.eventually.include('Cannot GET').notify(done);
});
});
describe('index route', function () { describe('index route', function () {
const body = fs.readFileSync(path.join(__dirname, '..', 'site', 'index.html')).toString(); const body = fs.readFileSync(path.join(__dirname, '..', 'site', 'index.html')).toString();