diff --git a/test/acceptance/label-wrap.js b/test/acceptance/label-wrap.js new file mode 100644 index 00000000..e520953e --- /dev/null +++ b/test/acceptance/label-wrap.js @@ -0,0 +1,69 @@ +require('../support/test_helper'); +var TestClient = require('../support/test-client'); + +var assert = require('../support/assert'); +var IMAGE_TOLERANCE = 20; + +describe('CartoCSS wrap', function () { + const options = { + sql: ` + 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, + 'South America' as continent + `, + cartocss: ` + #continent_points::labels { + text-name: [continent]; + text-face-name: 'Open Sans Italic'; + 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); + } + }); + + it.only("Label should be text-wrapped", function (done) { + this.testClient = new TestClient(mapConfig); + this.testClient.getTile(1, 0, 1, { layers: [0] }, (err, res, body) => { + var textWrapPath = './test/fixtures/text_wrap.png'; + assert.imageIsSimilarToFile(body, textWrapPath, IMAGE_TOLERANCE, done); + }); + }); +}); diff --git a/test/fixtures/text_wrap.png b/test/fixtures/text_wrap.png new file mode 100644 index 00000000..96774343 Binary files /dev/null and b/test/fixtures/text_wrap.png differ diff --git a/test/fixtures/text_wrap_bad.png b/test/fixtures/text_wrap_bad.png new file mode 100644 index 00000000..00fe47f7 Binary files /dev/null and b/test/fixtures/text_wrap_bad.png differ