test query params are an object

This commit is contained in:
Jeff Miccolis 2016-03-29 13:35:56 -04:00 committed by Patrick Niklaus
parent 07f3e2d457
commit 6a65261765
6 changed files with 18 additions and 9 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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);
});

View File

@ -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();

View File

@ -3,9 +3,12 @@ var request = require('request');
module.exports = function () {
this.paramsToString = (params) => {
var paramString = params.coordinates.join(';') + '.' + 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('&');
}

View File

@ -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);
};