cartodb-4.42/lib/assets/javascripts/cdb/test/spec/geo/common.spec.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
describe('common', function() {
var common;
beforeEach(function() {
common = new CartoDBLayerCommon();
common.options = {
tiler_domain: "carto.com",
tiler_port: "8081",
tiler_protocol: "http",
user_name: 'rambo',
table_name: 'test'
}
});
it("when query_wrapper is present the query should be wrapped", function() {
common.options = {
table_name: 'test',
tiler_domain: "carto.com",
tiler_port: "8081",
tiler_protocol: "http",
tile_style: "TEST",
query: 'select jaja',
query_wrapper: 'select * from (<%=sql%>)',
tile_style: '#test { polygon-fill: red; }',
interactivity: 'jaja'
}
var t = common._getLayerDefinition();
expect(t.sql).toEqual('select * from (select jaja)');
expect(t.cartocss).toEqual('#layer0 { polygon-fill: red; }');
expect(t.interactivity).toEqual('jaja');
common.options = {
table_name: 'test',
tiler_domain: "carto.com",
tiler_port: "8081",
tiler_protocol: "http",
tile_style: "TEST",
query: null,
query_wrapper: 'select * from (<%=sql%>)'
};
t = common._getLayerDefinition();
expect(t.sql).toEqual('select * from (select * from test)');
});
});