Windshaft-cartodb/test/acceptance/ported/wrap-test.js

121 lines
4.4 KiB
JavaScript
Raw Normal View History

'use strict';
require('../../support/test-helper');
2015-07-08 05:46:58 +08:00
var assert = require('../../support/assert');
var testClient = require('./support/test-client');
2015-07-08 05:46:58 +08:00
2019-10-22 01:07:24 +08:00
describe('wrap x coordinate', function () {
describe('renders correct tile', function () {
2015-07-08 05:46:58 +08:00
var IMG_TOLERANCE_PER_MIL = 20;
2019-10-22 01:07:24 +08:00
function plainTorqueMapConfig (plainColor) {
2015-07-08 05:46:58 +08:00
return {
version: '1.2.0',
layers: [
{
type: 'plain',
options: {
color: plainColor
}
},
{
type: 'torque',
options: {
2019-10-22 01:07:24 +08:00
sql: 'SELECT * FROM populated_places_simple_reduced ' +
'where the_geom && ST_MakeEnvelope(-90, 0, 90, 65)',
2015-07-08 05:46:58 +08:00
cartocss: [
'Map {',
' buffer-size:0;',
' -torque-frame-count:1;',
' -torque-animation-duration:30;',
' -torque-time-attribute:"cartodb_id";',
' -torque-aggregation-function:"count(cartodb_id)";',
' -torque-resolution:1;',
' -torque-data-aggregation:linear;',
'}',
'#populated_places_simple_reduced{',
' comp-op: multiply;',
' marker-fill-opacity: 1;',
' marker-line-color: #FFF;',
' marker-line-width: 0;',
' marker-line-opacity: 1;',
' marker-type: rectangle;',
' marker-width: 3;',
' marker-fill: #FFCC00;',
'}'
].join(' '),
cartocss_version: '2.3.0'
}
}
]
};
}
var testScenarios = [
{
tile: {
z: 2,
x: -2,
y: 1,
layer: 'all',
format: 'png'
},
fixture: {
z: 2,
x: 2,
y: 1
},
plainColor: 'white'
},
{
tile: {
z: 2,
x: -3,
y: 1,
layer: 'all',
format: 'png'
},
fixture: {
z: 2,
x: 1,
y: 1
},
plainColor: '#339900'
}
];
2019-10-22 01:07:24 +08:00
function blendPngFixture (zxy) {
2015-07-08 05:46:58 +08:00
return './test/fixtures/blend/blend-plain-torque-' + zxy.join('.') + '.png';
}
2019-10-22 01:07:24 +08:00
testScenarios.forEach(function (testScenario) {
2015-07-08 05:46:58 +08:00
var tileRequest = testScenario.tile;
var zxy = [tileRequest.z, tileRequest.x, tileRequest.y];
var fixtureZxy = [testScenario.fixture.z, testScenario.fixture.x, testScenario.fixture.y];
it('tile all/' + zxy.join('/') + '.png', function (done) {
2019-10-22 01:07:24 +08:00
testClient.getTileLayer(plainTorqueMapConfig(testScenario.plainColor), tileRequest, function (err, res) {
2016-02-22 23:36:06 +08:00
assert.imageBufferIsSimilarToFile(res.body, blendPngFixture(fixtureZxy), IMG_TOLERANCE_PER_MIL,
2019-10-22 01:07:24 +08:00
function (err) {
2016-02-22 23:36:06 +08:00
assert.ok(!err);
done();
}
);
2015-07-08 05:46:58 +08:00
});
});
});
});
2019-10-22 01:07:24 +08:00
describe('mapnik', function () {
it('can get a tile with negative x coordinate', function (done) {
testClient.getTile(testClient.defaultTableMapConfig('test_table'), 2, -2, 1, function (err, res, img) {
2015-07-08 05:46:58 +08:00
assert.ok(!err);
assert.ok(img);
assert.equal(img.width(), 256);
assert.equal(img.height(), 256);
done();
});
});
});
});