upgrade koa-static
This commit is contained in:
@ -48,7 +48,7 @@
|
|||||||
"koa-route": "^3",
|
"koa-route": "^3",
|
||||||
"koa-send": "^3.1.0",
|
"koa-send": "^3.1.0",
|
||||||
"koa-serve-index": "^1.1.0",
|
"koa-serve-index": "^1.1.0",
|
||||||
"koa-static": "^1.5.2",
|
"koa-static": "^2.0.0",
|
||||||
"path-to-regexp": "^1.2.1",
|
"path-to-regexp": "^1.2.1",
|
||||||
"stream-log-stats": "^1.1.2",
|
"stream-log-stats": "^1.1.2",
|
||||||
"string-tools": "^1.0.0",
|
"string-tools": "^1.0.0",
|
||||||
|
33
test/static.js
Normal file
33
test/static.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
'use strict'
|
||||||
|
const test = require('tape')
|
||||||
|
const request = require('req-then')
|
||||||
|
const localWebServer = require('../')
|
||||||
|
const http = require('http')
|
||||||
|
|
||||||
|
function launchServer (app, options) {
|
||||||
|
options = options || {}
|
||||||
|
const path = `http://localhost:8100${options.path || '/'}`
|
||||||
|
const server = http.createServer(app.callback())
|
||||||
|
return server.listen(options.port || 8100, () => {
|
||||||
|
const req = request(path, options.reqOptions)
|
||||||
|
if (options.onSuccess) req.then(options.onSuccess)
|
||||||
|
if (!options.leaveOpen) req.then(() => server.close())
|
||||||
|
req.catch(err => console.error('LAUNCH ERROR', err.stack))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
test('static', function (t) {
|
||||||
|
t.plan(1)
|
||||||
|
const app = localWebServer({
|
||||||
|
log: { format: 'none' },
|
||||||
|
static: {
|
||||||
|
root: __dirname + '/fixture',
|
||||||
|
options: {
|
||||||
|
index: 'file.txt'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
launchServer(app, { onSuccess: response => {
|
||||||
|
t.ok(/test/.test(response.data))
|
||||||
|
}})
|
||||||
|
})
|
16
test/test.js
16
test/test.js
@ -24,22 +24,6 @@ function checkResponse (t, status, body) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test('static', function (t) {
|
|
||||||
t.plan(1)
|
|
||||||
const app = localWebServer({
|
|
||||||
log: { format: 'none' },
|
|
||||||
static: {
|
|
||||||
root: __dirname + '/fixture',
|
|
||||||
options: {
|
|
||||||
index: 'file.txt'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
launchServer(app, { onSuccess: response => {
|
|
||||||
t.ok(/test/.test(response.data))
|
|
||||||
}})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('serve-index', function (t) {
|
test('serve-index', function (t) {
|
||||||
t.plan(2)
|
t.plan(2)
|
||||||
const app = localWebServer({
|
const app = localWebServer({
|
||||||
|
Reference in New Issue
Block a user