From f0d190d1572e9dca747f38aba24dd84896d7c0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Fri, 22 Jun 2018 17:31:05 +0200 Subject: [PATCH] tests tiles base urls with api key --- test/acceptance/layergroup-metadata.js | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/acceptance/layergroup-metadata.js diff --git a/test/acceptance/layergroup-metadata.js b/test/acceptance/layergroup-metadata.js new file mode 100644 index 00000000..57b21f8b --- /dev/null +++ b/test/acceptance/layergroup-metadata.js @@ -0,0 +1,46 @@ +require('../support/test_helper'); + +const assert = require('../support/assert'); +const TestClient = require('../support/test-client'); + +describe('layergroup metadata', function () { + [1234, false].forEach(api_key => { + it(`tiles base urls ${api_key ? 'with api key' : 'without api key'}`, function (done) { + const mapConfig = { + version: '1.7.0', + layers: [ + { + type: 'cartodb', + options: { + sql: 'select * from populated_places_simple_reduced', + } + } + ] + }; + + const host = `https://localhost.localhost.lan:${global.environment.port}`; + + const testClient = new TestClient(mapConfig, api_key); + testClient.getLayergroup((err, body) => { + if (err) { + return done(err); + } + + let urlLayer = `${host}/api/v1/map/${body.layergroupid}/layer0/{z}/{x}/{y}.mvt`; + let urlNoLayer = `${host}/api/v1/map/${body.layergroupid}/{z}/{x}/{y}.mvt`; + + if (api_key) { + urlLayer += `?api_key=${api_key}`; + urlNoLayer += `?api_key=${api_key}`; + } + + assert.ok(body.layergroupid); + assert.equal(body.metadata.layers[0].tilejson.vector.tiles[0], urlLayer); + assert.equal(body.metadata.tilejson.vector.tiles[0], urlNoLayer); + assert.equal(body.metadata.url.vector.urlTemplate, urlNoLayer); + + testClient.drain(done); + }); + }); + }); +});