2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 16:44:45 +08:00
|
|
|
require('../support/test-helper');
|
2018-01-11 05:20:19 +08:00
|
|
|
var TestClient = require('../support/test-client');
|
|
|
|
|
|
|
|
var assert = require('../support/assert');
|
2018-01-11 18:57:36 +08:00
|
|
|
var IMAGE_TOLERANCE = 5;
|
2018-01-11 05:20:19 +08:00
|
|
|
|
|
|
|
describe('CartoCSS wrap', function () {
|
|
|
|
const options = {
|
|
|
|
sql: `
|
2018-10-24 00:39:02 +08:00
|
|
|
SELECT
|
|
|
|
5 as cartodb_id,
|
|
|
|
ST_Transform(ST_SetSRID(ST_MakePoint(-57.65625,-15.6230368),4326),3857) as the_geom_webmercator,
|
|
|
|
ST_SetSRID(ST_MakePoint(-57.65625,-15.62303683),4326) as the_geom,
|
2018-01-11 05:20:19 +08:00
|
|
|
'South America' as continent
|
|
|
|
`,
|
|
|
|
cartocss: `
|
|
|
|
#continent_points::labels {
|
|
|
|
text-name: [continent];
|
2018-01-11 19:09:04 +08:00
|
|
|
text-face-name: 'DejaVu Sans Book';
|
2018-01-11 05:20:19 +08:00
|
|
|
text-size: 10;
|
|
|
|
text-fill: lighten(#000,40);
|
|
|
|
text-transform: uppercase;
|
|
|
|
text-wrap-width: 30;
|
|
|
|
text-character-spacing: 2;
|
|
|
|
text-placement: point;
|
|
|
|
text-placement-type: dummy;
|
|
|
|
[zoom >= 3]{
|
|
|
|
text-character-spacing: 2;
|
|
|
|
text-size: 11;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
cartocss_version: '3.0.12'
|
|
|
|
};
|
|
|
|
|
|
|
|
const type = 'mapnik';
|
|
|
|
|
|
|
|
const mapConfig = {
|
|
|
|
version: '1.6.0',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
type,
|
|
|
|
id: 'layerLabel',
|
|
|
|
options
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
var keysToDelete;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
keysToDelete = {};
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
if (this.testClient) {
|
|
|
|
this.testClient.drain(done);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('Label should be text-wrapped', function (done) {
|
2018-01-11 05:20:19 +08:00
|
|
|
this.testClient = new TestClient(mapConfig);
|
|
|
|
this.testClient.getTile(1, 0, 1, { layers: [0] }, (err, res, body) => {
|
2019-10-25 00:38:37 +08:00
|
|
|
assert.ifError(err);
|
2018-01-11 05:20:19 +08:00
|
|
|
var textWrapPath = './test/fixtures/text_wrap.png';
|
|
|
|
assert.imageIsSimilarToFile(body, textWrapPath, IMAGE_TOLERANCE, done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|