From d844440a30a2ae6ddce0ff59af6c7572041f9bb4 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 13 May 2018 12:17:09 +0900 Subject: Fix debug web-server on e2e testing --- e2e/web-server/index.js | 28 +++++++++++++++++++--------- e2e/web-server/url.js | 5 +++++ 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 e2e/web-server/url.js (limited to 'e2e/web-server') diff --git a/e2e/web-server/index.js b/e2e/web-server/index.js index 81e11c1..8710bf9 100644 --- a/e2e/web-server/index.js +++ b/e2e/web-server/index.js @@ -1,14 +1,24 @@ +var serverUrl = require('./url'); var http = require('http'); +var url = require('url'); -const content = -'' + -'' + - '' + - '' + -'' ; +const handleScroll = (req, res) => { + res.writeHead(200, {'Content-Type': 'text/html'}); + res.end(''); +}; +const handle404 = (req, res) => { + res.writeHead(404, {'Content-Type': 'text/plain'}); + res.end('not found') +}; http.createServer(function (req, res) { - res.writeHead(200, {'Content-Type': 'text/html'}); - res.end(content); -}).listen(11111, '127.0.0.1'); + let u = url.parse(req.url); + if (req.method === 'GET' && u.pathname === '/scroll') { + handleScroll(req, res); + } else { + handle404(req, res); + } + + console.log(`"${req.method} ${req.url}"`, res.statusCode) +}).listen(serverUrl.PORT, serverUrl.HOST); diff --git a/e2e/web-server/url.js b/e2e/web-server/url.js new file mode 100644 index 0000000..37f3d84 --- /dev/null +++ b/e2e/web-server/url.js @@ -0,0 +1,5 @@ +module.exports = { + PORT: 11111, + HOST: '127.0.0.1', + CLIENT_URL: 'http://127.0.0.1:11111', +} -- cgit v1.2.3