implement mime-type overrides.. tests.

This commit is contained in:
Lloyd Brookes
2015-11-13 11:26:02 +00:00
parent b615ffe4e0
commit 69db357661
6 changed files with 48 additions and 34 deletions

View File

@ -5,6 +5,17 @@ const localWebServer = require('../')
const http = require('http')
const PassThrough = require('stream').PassThrough
function launchServer (app, reqOptions, path, onSuccess) {
path = `http://localhost:8100${path || '/'}`
const server = http.createServer(app.callback())
server.listen(8100, () => {
const req = request(path, reqOptions)
if (onSuccess) req.then(onSuccess)
req.then(() => server.close())
req.catch(err => console.error('LAUNCH ERROR', err.stack))
})
}
test('log: common', function (t) {
t.plan(1)
const stream = PassThrough()
@ -70,13 +81,14 @@ test('compress', function(t){
})
})
function launchServer (app, reqOptions, path, onSuccess) {
path = `http://localhost:8100${path || '/'}`
const server = http.createServer(app.callback())
server.listen(8100, () => {
const req = request(path, reqOptions)
if (onSuccess) req.then(onSuccess)
req.then(() => server.close())
req.catch(err => console.error('LAUNCH ERROR', err.stack))
test('mime', function(t){
t.plan(1)
const app = localWebServer({
log: { format: 'none' },
static: { root: __dirname + '/static' },
mime: { 'text/plain': [ 'php' ]}
})
}
launchServer(app, null, '/something.php', response => {
t.ok(/text\/plain/.test(response.res.headers['content-type']))
})
})