Split out 404 tests
This commit is contained in:
parent
dbce552acb
commit
630063f012
3 changed files with 21 additions and 16 deletions
|
@ -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": {
|
||||||
|
|
20
tests/middleware/404.test.ts
Normal file
20
tests/middleware/404.test.ts
Normal 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -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();
|
||||||
|
|
||||||
|
|
Reference in a new issue