From dd89ef5767c592d5dcbb182c68b2e318ca7973ef Mon Sep 17 00:00:00 2001 From: Jon Nordby Date: Mon, 22 Aug 2016 14:30:57 +0800 Subject: [PATCH 1/2] Tests: More failing fun --- spec/runner.coffee | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/spec/runner.coffee b/spec/runner.coffee index 5c81f08..7d54aa3 100644 --- a/spec/runner.coffee +++ b/spec/runner.coffee @@ -366,7 +366,7 @@ describe 'Runner', -> chai.expect(err.message).to.contain 'TIMEOUT' done() - describe 'input data containing ', -> + describe 'input data containing ', -> it 'should succeed', (done) -> filter = local 'return-input' input = { 'foo': 'barbaz', 'htmlscript': '' } @@ -376,6 +376,26 @@ describe 'Runner', -> chai.expect(solution).to.eql input done() + describe 'input data containing ... " for s in options.scripts).join("\n") body = """ @@ -85,7 +95,6 @@ generateHtml = (filter, page, options) -> #{scriptTags} - @@ -186,11 +195,25 @@ class Runner jobId = paths[2] if paths[3] == 'event' return @handleEventRequest jobId, request, response + else if paths[3] == 'data' + return @handleDataRequest jobId, request, response else return response.end() else return response.end() + handleDataRequest: (jobId, request, response) -> + console.log "#{request.method} #{jobId}" if @options.verbose + job = @jobs[jobId] + if not job + # multiple callbacks for same id, or wrong id + debug 'could not find solve job', jobId + return + + response.writeHead 200, {"Content-Type": "application/json; charset=utf-8"} + body = JSON.stringify { input: job.page, options: job.options } + response.end body + handleSolveRequest: (jobId, request, response) -> console.log "#{request.method} #{jobId}" if @options.verbose job = @jobs[jobId] @@ -200,9 +223,8 @@ class Runner return if request.method == 'GET' - # FIXME: make only for GET response.writeHead 200, {"Content-Type": "text/html; charset=utf-8"} - body = generateHtml job.filter, job.page, job.options + body = generateHtml job.filter, job.options response.end body else if request.method == 'POST' data = ""