From ba8589a6ba3072649344d1b03db111e22ad3f796 Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Tue, 17 Nov 2015 16:13:57 +0000 Subject: [PATCH] SPA tests --- test/fixture/spa/one.txt | 1 + test/fixture/spa/two.txt | 1 + test/test.js | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 test/fixture/spa/one.txt create mode 100644 test/fixture/spa/two.txt diff --git a/test/fixture/spa/one.txt b/test/fixture/spa/one.txt new file mode 100644 index 0000000..5626abf --- /dev/null +++ b/test/fixture/spa/one.txt @@ -0,0 +1 @@ +one diff --git a/test/fixture/spa/two.txt b/test/fixture/spa/two.txt new file mode 100644 index 0000000..f719efd --- /dev/null +++ b/test/fixture/spa/two.txt @@ -0,0 +1 @@ +two diff --git a/test/test.js b/test/test.js index 51d767f..7e186b5 100644 --- a/test/test.js +++ b/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) { t.plan(1) const stream = PassThrough()