This commit is contained in:
Daniel García Aubert 2017-04-25 17:54:31 +02:00
parent f29ee1b4ac
commit 0577fa5308

View File

@ -26,7 +26,7 @@ var CARTOCSS_LABELS = [
' text-placement: point;',
' text-placement-type: dummy;',
'}'
].join('\n')
].join('\n');
function createMapConfig (bufferSize, cartocss) {
cartocss = cartocss || CARTOCSS_LABELS;
@ -99,7 +99,7 @@ describe('buffer size per format', function () {
mapConfig: createMapConfig({ mvt: 128 }),
assert: function (tile, callback) {
var tileJSON = tile.toJSON();
var features = tileJSON[0].features
var features = tileJSON[0].features;
assert.equal(features.length, 9);
var map = new mapnik.Map(256, 256);
@ -127,39 +127,23 @@ describe('buffer size per format', function () {
});
});
function createBufferSizeTemplate (name, cartocss) {
function createBufferSizeTemplate (name, buffersize, placeholders, cartocss) {
cartocss = cartocss || CARTOCSS_LABELS;
return {
"version": "0.0.1",
"name": name,
"placeholders": {
"placeholders": placeholders || {
"buffersize": {
"type": "number",
"default": "0"
}
},
"layergroup": {
version: '1.6.0',
buffersize: '<%= buffersize %>',
layers: [{
type: 'cartodb',
options: {
sql: [
'select',
' *',
'from',
' populated_places_simple_reduced',
].join('\n'),
cartocss: cartocss,
cartocss_version: '2.3.0',
interactivity: 'cartodb_id'
}
}]
}
"layergroup": createMapConfig(buffersize)
}
}
describe('buffer size per format for named maps', function () {
describe.only('buffer size per format for named maps', function () {
var testCases = [
{
desc: 'should get png tile using buffer-size 0 (default value in template)',
@ -181,6 +165,41 @@ describe('buffer size per format for named maps', function () {
assert: function (tile, callback) {
assert.imageIsSimilarToFile(tile, this.fixturePath, IMAGE_TOLERANCE_PER_MIL, callback);
}
},
{
desc: 'should get png tile using buffer-size 0 (default value in template by format)',
coords: { z: 7, x: 64, y: 48 },
format: 'png',
fixturePath: './test/fixtures/buffer-size/tile-7.64.48-buffer-size-0.png',
template: createBufferSizeTemplate('named-default-buffer-size-by-format', {
png: '<%= buffersize_png %>'
}, {
"buffersize_png": {
"type": "number",
"default": "0"
}
}),
assert: function (tile, callback) {
assert.imageIsSimilarToFile(tile, this.fixturePath, IMAGE_TOLERANCE_PER_MIL, callback);
}
},
{
desc: 'should get png tile using buffer-size 128 (placehoder value in template by format)',
coords: { z: 7, x: 64, y: 48 },
format: 'png',
placeholders: { buffersize: 128 },
fixturePath: './test/fixtures/buffer-size/tile-7.64.48-buffer-size-128.png',
template: createBufferSizeTemplate('named-custom-buffer-size-by-format', {
png: '<%= buffersize_png %>'
}, {
"buffersize_png": {
"type": "number",
"default": "0"
}
}),
assert: function (tile, callback) {
assert.imageIsSimilarToFile(tile, this.fixturePath, IMAGE_TOLERANCE_PER_MIL, callback);
}
}
];