From 0fcdb4b8e692334da092d1c4c58eb14b007dbcd2 Mon Sep 17 00:00:00 2001 From: Jeff Miccolis Date: Tue, 29 Mar 2016 13:35:56 -0400 Subject: [PATCH] test query params are an object --- features/step_definitions/hooks.js | 2 +- features/step_definitions/options.js | 4 ++-- features/step_definitions/requests.js | 2 +- features/support/hooks.js | 2 +- features/support/http.js | 9 ++++++--- features/support/route.js | 8 +++++++- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/features/step_definitions/hooks.js b/features/step_definitions/hooks.js index dbc0930b7..07b47195a 100644 --- a/features/step_definitions/hooks.js +++ b/features/step_definitions/hooks.js @@ -5,7 +5,7 @@ module.exports = function () { this.scenarioTitle = scenario.getName(); this.loadMethod = this.DEFAULT_LOAD_METHOD; - this.queryParams = []; + this.queryParams = {}; var d = new Date(); this.scenarioTime = util.format('%d-%d-%dT%s:%s:%sZ', d.getFullYear(), d.getMonth()+1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()); this.resetData(); diff --git a/features/step_definitions/options.js b/features/step_definitions/options.js index fbc4eb361..29df0ed89 100644 --- a/features/step_definitions/options.js +++ b/features/step_definitions/options.js @@ -60,8 +60,8 @@ module.exports = function () { }); this.Given(/^the query options$/, (table, callback) => { - table.raw().forEach((tuple) => { - this.queryParams.push(tuple); + table.raw().forEach(tuple => { + this.queryParams[tuple[0]] = tuple[1] }); callback(); diff --git a/features/step_definitions/requests.js b/features/step_definitions/requests.js index effc5e12c..dcaf5cc5f 100644 --- a/features/step_definitions/requests.js +++ b/features/step_definitions/requests.js @@ -3,7 +3,7 @@ var assert = require('assert'); module.exports = function () { this.When(/^I request \/(.*)$/, (path, callback) => { this.reprocessAndLoadData(() => { - this.requestPath(path, [], (err, res, body) => { + this.requestPath(path, {}, (err, res, body) => { this.response = res; callback(err, res, body); }); diff --git a/features/support/hooks.js b/features/support/hooks.js index 4f03e2d88..f8c7a2f65 100644 --- a/features/support/hooks.js +++ b/features/support/hooks.js @@ -12,7 +12,7 @@ module.exports = function () { this.scenarioTitle = scenario.getName(); this.loadMethod = this.DEFAULT_LOAD_METHOD; - this.queryParams = []; + this.queryParams = {}; var d = new Date(); this.scenarioTime = util.format('%d-%d-%dT%s:%s:%sZ', d.getFullYear(), d.getMonth()+1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()); this.resetData(); diff --git a/features/support/http.js b/features/support/http.js index d78bdc4a0..bd9b9f870 100644 --- a/features/support/http.js +++ b/features/support/http.js @@ -3,9 +3,12 @@ var request = require('request'); module.exports = function () { this.paramsToString = (params) => { - var paramString = params.coordinates.join(';') + '.' + params.output; - delete params.coordinates; - delete params.output; + var paramString = ''; + if (params.coordinates !== undefined && params.output !== undefined) { + paramString = params.coordinates.join(';') + '.' + params.output; + delete params.coordinates; + delete params.output; + } if (Object.keys(params).length) { paramString += '?' + Object.keys(params).map(k => k + '=' + params[k]).join('&'); } diff --git a/features/support/route.js b/features/support/route.js index 09230e1b1..591a6be4a 100644 --- a/features/support/route.js +++ b/features/support/route.js @@ -3,7 +3,13 @@ var request = require('request'); module.exports = function () { this.requestPath = (service, params, callback) => { - var uri = [this.HOST, service, 'v1', this.profile].join('/'); + var uri; + if (service == 'timestamp') { + uri = [this.HOST, service].join('/'); + } else { + uri = [this.HOST, service, 'v1', this.profile].join('/'); + } + return this.sendRequest(uri, params, callback); };