This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
tstatic/tests/server.test.ts

58 lines
1.8 KiB
TypeScript
Raw Normal View History

2017-02-19 18:19:45 +00:00
import { expect } from 'chai';
import { runServer } from './helpers';
2017-02-19 19:01:53 +00:00
import * as fs from 'fs';
2017-02-19 22:01:43 +00:00
import * as path from 'path';
2017-02-19 18:19:45 +00:00
describe('Server', function () {
it('Should be usable', function (done) {
runServer({
allowed_ips: [],
basicAuth: [],
dirList: false,
serveDir: 'site/',
opbeat: false,
open: false
}, '/index.html', function (response : any) {
expect(response.status).to.equal(200);
expect(response.url).to.include('/index.html');
done();
});
});
2017-02-19 19:01:53 +00:00
2017-05-06 22:59:29 +01:00
it('Should nave no x-powered-by header', function (done) {
runServer({
allowed_ips: [],
basicAuth: [],
dirList: false,
serveDir: 'site/',
opbeat: false,
open: false
}, '/index.html', function (response : any) {
expect(response.status).to.equal(200);
expect(response.headers.get('x-powered-by')).to.equal(null);
done();
});
});
2017-02-19 19:01:53 +00:00
describe('index route', function () {
2017-02-19 22:01:43 +00:00
const body = fs.readFileSync(path.join(__dirname, '..', 'site', 'index.html')).toString();
2017-02-19 19:01:53 +00:00
['', '/', '/index.html'].forEach(function (path : string) {
it('should render ' + path, function (done) {
runServer({
allowed_ips: [],
basicAuth: [],
dirList: false,
serveDir: 'site/',
opbeat: false,
open: false
}, path, function (response : any) {
expect(response.status).to.equal(200);
2017-02-19 21:53:06 +00:00
expect(response.text()).to.eventually.equal(body).notify(done);
2017-02-19 19:01:53 +00:00
});
});
});
});
2017-02-19 18:19:45 +00:00
});