SPA tests
This commit is contained in:
1
test/fixture/spa/one.txt
Normal file
1
test/fixture/spa/one.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
one
|
1
test/fixture/spa/two.txt
Normal file
1
test/fixture/spa/two.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
two
|
19
test/test.js
19
test/test.js
@ -50,6 +50,25 @@ test('serve-index', function (t) {
|
|||||||
}})
|
}})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('single page app', function(t){
|
||||||
|
t.plan(4)
|
||||||
|
const app = localWebServer({
|
||||||
|
log: { format: 'none' },
|
||||||
|
static: { root: __dirname + '/fixture/spa' },
|
||||||
|
spa: 'one.txt'
|
||||||
|
})
|
||||||
|
const server = launchServer(app, { leaveOpen: true })
|
||||||
|
request('http://localhost:8100/test').then(response => {
|
||||||
|
t.strictEqual(response.res.statusCode, 200)
|
||||||
|
t.strictEqual(response.data, 'one\n')
|
||||||
|
request('http://localhost:8100/two.txt').then(response => {
|
||||||
|
t.strictEqual(response.res.statusCode, 200)
|
||||||
|
t.strictEqual(response.data, 'two\n')
|
||||||
|
server.close()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
test('log: common', function (t) {
|
test('log: common', function (t) {
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
const stream = PassThrough()
|
const stream = PassThrough()
|
||||||
|
Reference in New Issue
Block a user