archive
/
tstatic
Archived
1
Fork 0

Cleanup tests

This commit is contained in:
Jake Howard 2017-02-19 21:53:06 +00:00
parent 8fa136379f
commit 53df4c6e3f
7 changed files with 15 additions and 10 deletions

View File

@ -11,7 +11,7 @@
"postinstall": "typings install",
"build": "tsc",
"test": "npm run build && npm run mocha && nsp check",
"mocha": "NODE_ENV=test mocha --compilers ts:ts-node/register --require scripts/test-helper.js src/__tests__/**.test.ts",
"mocha": "mocha --compilers ts:ts-node/register --require scripts/test-helper.js src/__tests__/**.test.ts",
"lint": "tslint src/**/*.ts"
},
"engines": {
@ -43,6 +43,7 @@
},
"devDependencies": {
"chai": "=3.5.0",
"chai-as-promised": "=6.0.0",
"mocha": "=3.2.0",
"node-fetch": "=1.6.3",
"nsp": "=2.6.2",

View File

@ -1,3 +1,7 @@
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.expect();
chai.use(chaiAsPromised);
process.env.NODE_ENV = 'test';

View File

@ -33,7 +33,8 @@ describe('Server', function () {
open: false
}, '/foo/bar', function (response : any) {
expect(response.ok).to.be.false;
done();
expect(response.status).to.equal(404);
expect(response.text()).to.eventually.include('Cannot GET').notify(done);
});
});
@ -51,10 +52,7 @@ describe('Server', function () {
open: false
}, path, function (response : any) {
expect(response.status).to.equal(200);
response.text().then(function (text : any) {
expect(text).to.equal(body);
done();
});
expect(response.text()).to.eventually.equal(body).notify(done);
});
});
});

View File

@ -1,6 +1,6 @@
import { Request, Response } from 'express';
import staticFile from 'connect-static-file'
import path from 'path';
import * as staticFile from 'connect-static-file'
import * as path from 'path';
export default function handle404(serveDir : string) {
const handle404Middleware = staticFile(path.join(serveDir, '.404.html'));

View File

@ -39,7 +39,7 @@ export default function createServer(opts : Options) : express.Application {
}
app.use(staticFileHandle(opts.serveDir));
app.use(handle404);
app.use(handle404(opts.serveDir));
app.use(compression({ level: 9 }));
app.use(helmet());

View File

@ -9,3 +9,4 @@ declare module 'opbeat';
declare module 'docopt';
declare module 'open';
declare module 'node-fetch';
declare module 'chai';

View File

@ -17,7 +17,8 @@
"exclude": [
"dist",
"node_modules",
"scripts/"
"scripts/",
"src/__tests__"
],
"typeRoots": [
"node_modules",