From b97aeda53c2db65d4e5cc3a6a6259474b17dfec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 26 May 2020 16:52:13 +0200 Subject: [PATCH] Adapt test-client to handle client query param --- test/support/test-client.js | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/test/support/test-client.js b/test/support/test-client.js index c3204249..96a61da1 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -942,24 +942,8 @@ TestClient.prototype.getLayergroup = function (params, callback) { params = {}; } - let url = '/api/v1/map'; - const urlNamed = url + '/named'; const headers = Object.assign({ host: 'localhost', 'Content-Type': 'application/json' }, self.extraHeaders); - const queryParams = {}; - - if (self.apiKey) { - queryParams.api_key = self.apiKey; - } - - if (params.aggregation !== undefined) { - queryParams.aggregation = params.aggregation; - } - - if (Object.keys(queryParams).length) { - url += '?' + qs.stringify(queryParams); - } - var layergroupId; if (params.layergroupid) { @@ -982,7 +966,7 @@ TestClient.prototype.getLayergroup = function (params, callback) { assert.response(self.server, { - url: urlNamed + '?' + qs.stringify({ api_key: self.apiKey }), + url: `/api/v1/map/named?${qs.stringify({ api_key: self.apiKey })}`, method: 'POST', headers, data: JSON.stringify(self.template) @@ -1023,9 +1007,10 @@ TestClient.prototype.getLayergroup = function (params, callback) { }; } + const url = '/api/v1/map'; const queryParams = {}; - if (self.apiKey) { + if (self.apiKey !== undefined) { queryParams.api_key = self.apiKey; } @@ -1038,8 +1023,8 @@ TestClient.prototype.getLayergroup = function (params, callback) { } const path = templateId - ? `${urlNamed}/${templateId}?${qs.stringify(queryParams)}` - : `${url}?${qs.stringify(queryParams)}`; + ? `${url}/named/${templateId}${Object.keys(queryParams).length ? `?${qs.stringify(queryParams)}` : ''}` + : `${url}${Object.keys(queryParams).length ? `?${qs.stringify(queryParams)}` : ''}`; assert.response(self.server, {