2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 16:44:45 +08:00
|
|
|
require('../support/test-helper');
|
2016-05-19 19:32:32 +08:00
|
|
|
|
|
|
|
var assert = require('../support/assert');
|
|
|
|
var TestClient = require('../support/test-client');
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
describe('sql-wrap', function () {
|
|
|
|
afterEach(function (done) {
|
2016-05-19 19:32:32 +08:00
|
|
|
if (this.testClient) {
|
|
|
|
this.testClient.drain(done);
|
|
|
|
} else {
|
|
|
|
return done();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('should use sql_wrap from layer options', function (done) {
|
2016-05-19 19:32:32 +08:00
|
|
|
var mapConfig = {
|
|
|
|
version: '1.5.0',
|
|
|
|
layers: [
|
|
|
|
{
|
2019-10-22 01:07:24 +08:00
|
|
|
type: 'cartodb',
|
|
|
|
options: {
|
|
|
|
sql: 'SELECT * FROM populated_places_simple_reduced',
|
|
|
|
sql_wrap: "SELECT * FROM (<%= sql %>) _w WHERE adm0_a3 = 'USA'",
|
|
|
|
cartocss: [
|
|
|
|
'#points {',
|
|
|
|
' marker-fill-opacity: 1;',
|
|
|
|
' marker-line-color: #FFF;',
|
|
|
|
' marker-line-width: 0.5;',
|
|
|
|
' marker-line-opacity: 1;',
|
|
|
|
' marker-placement: point;',
|
|
|
|
' marker-type: ellipse;',
|
|
|
|
' marker-width: 8;',
|
|
|
|
' marker-fill: red;',
|
|
|
|
' marker-allow-overlap: true;',
|
|
|
|
'}'
|
2016-05-19 19:32:32 +08:00
|
|
|
].join('\n'),
|
2019-10-22 01:07:24 +08:00
|
|
|
cartocss_version: '2.3.0'
|
2016-05-19 19:32:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
this.testClient = new TestClient(mapConfig, 1234);
|
2019-10-22 01:07:24 +08:00
|
|
|
this.testClient.getTile(0, 0, 0, function (err, tile, img) {
|
2016-05-19 19:32:32 +08:00
|
|
|
assert.ok(!err, err);
|
|
|
|
var fixtureImg = './test/fixtures/sql-wrap-usa-filter.png';
|
|
|
|
assert.imageIsSimilarToFile(img, fixtureImg, 20, done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|