From 630063f0128a0d499c06d63020f5edef8408b8c5 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 27 Feb 2017 10:02:30 +0000 Subject: [PATCH] Split out 404 tests --- package.json | 2 +- tests/middleware/404.test.ts | 20 ++++++++++++++++++++ tests/server.test.ts | 15 --------------- 3 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 tests/middleware/404.test.ts diff --git a/package.json b/package.json index f0f66df..b3d50e7 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "prepublish": "typings install && npm run build", "build": "tsc", "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" }, "engines": { diff --git a/tests/middleware/404.test.ts b/tests/middleware/404.test.ts new file mode 100644 index 0000000..83708d4 --- /dev/null +++ b/tests/middleware/404.test.ts @@ -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); + }); + }); +}); diff --git a/tests/server.test.ts b/tests/server.test.ts index 0aef94c..84a22db 100644 --- a/tests/server.test.ts +++ b/tests/server.test.ts @@ -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 () { const body = fs.readFileSync(path.join(__dirname, '..', 'site', 'index.html')).toString();