Windshaft-cartodb/test/acceptance/layergroup-metadata-test.js

60 lines
2.0 KiB
JavaScript
Raw Normal View History

'use strict';
require('../support/test-helper');
2018-06-22 23:31:05 +08:00
const assert = require('../support/assert');
const TestClient = require('../support/test-client');
const serverOptions = require('../../lib/server-options');
2018-06-22 23:31:05 +08:00
describe('layergroup metadata', function () {
const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;
before(function () {
serverOptions.renderer.mvt.usePostGIS = true;
});
after(function () {
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
});
[1234, 'default_public', false].forEach(api_key => {
2018-06-25 21:09:18 +08:00
it(`tiles base urls ${api_key ? `with api key: ${api_key}` : 'without api key'}`, function (done) {
2018-06-22 23:31:05 +08:00
const mapConfig = {
version: '1.7.0',
layers: [
{
type: 'cartodb',
options: {
2019-10-22 01:07:24 +08:00
sql: 'select * from populated_places_simple_reduced'
2018-06-22 23:31:05 +08:00
}
}
]
};
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.strictEqual(body.metadata.layers[0].tilejson.vector.tiles[0], urlLayer);
assert.strictEqual(body.metadata.tilejson.vector.tiles[0], urlNoLayer);
assert.strictEqual(body.metadata.url.vector.urlTemplate, urlNoLayer);
2018-06-22 23:31:05 +08:00
testClient.drain(done);
});
});
});
});