Merge branch 'master' into fallback-reference
This commit is contained in:
commit
1873dc1ce3
@ -55,7 +55,7 @@ var carto = {
|
|||||||
if (typeof(extract[2]) === 'string') {
|
if (typeof(extract[2]) === 'string') {
|
||||||
error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey'));
|
error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey'));
|
||||||
}
|
}
|
||||||
error = options.indent + error.join('\n' + options.indent) + '\033[0m\n';
|
error = options.indent + error.join('\n' + options.indent) + '\x1B[0m\n';
|
||||||
|
|
||||||
message = options.indent + message + stylize(ctx.message, 'red');
|
message = options.indent + message + stylize(ctx.message, 'red');
|
||||||
if (ctx.filename) (message += stylize(' in ', 'red') + ctx.filename);
|
if (ctx.filename) (message += stylize(' in ', 'red') + ctx.filename);
|
||||||
@ -113,6 +113,6 @@ function stylize(str, style) {
|
|||||||
'red' : [31, 39],
|
'red' : [31, 39],
|
||||||
'grey' : [90, 39]
|
'grey' : [90, 39]
|
||||||
};
|
};
|
||||||
return '\033[' + styles[style][0] + 'm' + str +
|
return '\x1B[' + styles[style][0] + 'm' + str +
|
||||||
'\033[' + styles[style][1] + 'm';
|
'\x1B[' + styles[style][1] + 'm';
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"pretest": "npm install",
|
"pretest": "npm install",
|
||||||
"test": "mocha -R spec",
|
"test": "mocha -R spec",
|
||||||
|
"tdd" : "env HIDE_LOGS=true mocha -w -R spec",
|
||||||
"coverage": "istanbul cover ./node_modules/.bin/_mocha && coveralls < ./coverage/lcov.info"
|
"coverage": "istanbul cover ./node_modules/.bin/_mocha && coveralls < ./coverage/lcov.info"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
|
var SHOW_LOGS = (process.env.HIDE_LOGS !== 'true');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var carto = require('../lib/carto');
|
var carto = require('../lib/carto');
|
||||||
describe('RenderingJS', function() {
|
describe('RenderingJS', function() {
|
||||||
@ -21,7 +21,7 @@ describe('RenderingJS', function() {
|
|||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
shader = (new carto.RendererJS({ debug: true })).render(style);
|
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
});
|
});
|
||||||
|
|
||||||
it ("shold render layers", function() {
|
it ("shold render layers", function() {
|
||||||
@ -45,7 +45,7 @@ describe('RenderingJS', function() {
|
|||||||
|
|
||||||
it ("shold render variables", function() {
|
it ("shold render variables", function() {
|
||||||
var style = '#test { marker-width: [testing]; }';
|
var style = '#test { marker-width: [testing]; }';
|
||||||
shader = (new carto.RendererJS({ debug: true })).render(style);
|
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
var layer = shader.getLayers()[0];
|
var layer = shader.getLayers()[0];
|
||||||
var props = layer.getStyle({testing: 2}, { 'zoom': 0, 'frame-offset': 10 });
|
var props = layer.getStyle({testing: 2}, { 'zoom': 0, 'frame-offset': 10 });
|
||||||
assert( props['marker-width'] === 2);
|
assert( props['marker-width'] === 2);
|
||||||
@ -53,7 +53,7 @@ describe('RenderingJS', function() {
|
|||||||
|
|
||||||
it ("should allow filter based rendering", function() {
|
it ("should allow filter based rendering", function() {
|
||||||
var style = '#test { marker-width: 10; [zoom = 1] { marker-width: 1; } }';
|
var style = '#test { marker-width: 10; [zoom = 1] { marker-width: 1; } }';
|
||||||
shader = (new carto.RendererJS({ debug: true })).render(style);
|
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
var layer = shader.getLayers()[0];
|
var layer = shader.getLayers()[0];
|
||||||
var props = layer.getStyle({}, { 'zoom': 0, 'frame-offset': 10 });
|
var props = layer.getStyle({}, { 'zoom': 0, 'frame-offset': 10 });
|
||||||
assert( props['marker-width'] === 10);
|
assert( props['marker-width'] === 10);
|
||||||
@ -64,7 +64,7 @@ describe('RenderingJS', function() {
|
|||||||
it ("symbolizers should be in rendering order", function() {
|
it ("symbolizers should be in rendering order", function() {
|
||||||
var style = '#test { polygon-fill: red; line-color: red; }';
|
var style = '#test { polygon-fill: red; line-color: red; }';
|
||||||
style += '#test2 { line-color: red;polygon-fill: red; line-width: 10; }';
|
style += '#test2 { line-color: red;polygon-fill: red; line-width: 10; }';
|
||||||
var shader = (new carto.RendererJS({ debug: true })).render(style);
|
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
var layer0 = shader.getLayers()[0];
|
var layer0 = shader.getLayers()[0];
|
||||||
assert(layer0.getSymbolizers()[0] === 'polygon');
|
assert(layer0.getSymbolizers()[0] === 'polygon');
|
||||||
assert(layer0.getSymbolizers()[1] === 'line');
|
assert(layer0.getSymbolizers()[1] === 'line');
|
||||||
@ -76,7 +76,7 @@ describe('RenderingJS', function() {
|
|||||||
|
|
||||||
it ("colorize should return a list of colours in same order", function() {
|
it ("colorize should return a list of colours in same order", function() {
|
||||||
var style = '#test { image-filters: colorize-alpha(blue, cyan, green, yellow, orange, red); }';
|
var style = '#test { image-filters: colorize-alpha(blue, cyan, green, yellow, orange, red); }';
|
||||||
var shader = (new carto.RendererJS({ debug: true })).render(style);
|
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
var layer0 = shader.getLayers()[0];
|
var layer0 = shader.getLayers()[0];
|
||||||
var st = layer0.getStyle({ value: 1 }, {"frame-offset": 0, "zoom": 3});
|
var st = layer0.getStyle({ value: 1 }, {"frame-offset": 0, "zoom": 3});
|
||||||
var expectedColours = [[0, 0, 255], [0, 255, 255], [0, 128, 0], [255, 255, 0], [255, 165, 0], [255, 0, 0]];
|
var expectedColours = [[0, 0, 255], [0, 255, 255], [0, 128, 0], [255, 255, 0], [255, 165, 0], [255, 0, 0]];
|
||||||
@ -106,7 +106,7 @@ describe('RenderingJS', function() {
|
|||||||
' [frame-offset = 2] { marker-width: 15; marker-fill-opacity: 0.02;}',
|
' [frame-offset = 2] { marker-width: 15; marker-fill-opacity: 0.02;}',
|
||||||
'}'
|
'}'
|
||||||
].join('\n');
|
].join('\n');
|
||||||
var shader = (new carto.RendererJS({ debug: true })).render(css);
|
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(css);
|
||||||
var markerURLs = shader.getImageURLs();
|
var markerURLs = shader.getImageURLs();
|
||||||
var against = ["http://localhost:8081/gal.svg", "http://upload.wikimedia.org/wikipedia/commons/4/43/Flag_of_the_Galactic_Empire.svg", "http://upload.wikimedia.org/wikipedia/commons/c/c9/Flag_of_Syldavia.svg"];
|
var against = ["http://localhost:8081/gal.svg", "http://upload.wikimedia.org/wikipedia/commons/4/43/Flag_of_the_Galactic_Empire.svg", "http://upload.wikimedia.org/wikipedia/commons/c/c9/Flag_of_Syldavia.svg"];
|
||||||
for(var i = 0; i<against.length; i++){
|
for(var i = 0; i<against.length; i++){
|
||||||
@ -116,24 +116,24 @@ describe('RenderingJS', function() {
|
|||||||
|
|
||||||
it ("should return variable for styles that change", function() {
|
it ("should return variable for styles that change", function() {
|
||||||
var style = '#test { marker-width: [prop]; }';
|
var style = '#test { marker-width: [prop]; }';
|
||||||
var shader = (new carto.RendererJS({ debug: true })).render(style);
|
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
var layer0 = shader.getLayers()[0];
|
var layer0 = shader.getLayers()[0];
|
||||||
assert(layer0.isVariable());
|
assert(layer0.isVariable());
|
||||||
|
|
||||||
style = '#test { marker-width: 1; }';
|
style = '#test { marker-width: 1; }';
|
||||||
shader = (new carto.RendererJS({ debug: true })).render(style);
|
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
layer0 = shader.getLayers()[0];
|
layer0 = shader.getLayers()[0];
|
||||||
assert(!layer0.isVariable());
|
assert(!layer0.isVariable());
|
||||||
|
|
||||||
style = '#test { marker-width: [prop]; marker-fill: red; }';
|
style = '#test { marker-width: [prop]; marker-fill: red; }';
|
||||||
shader = (new carto.RendererJS({ debug: true })).render(style);
|
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
layer0 = shader.getLayers()[0];
|
layer0 = shader.getLayers()[0];
|
||||||
assert(layer0.isVariable());
|
assert(layer0.isVariable());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should parse styles with string", function() {
|
it("should parse styles with string", function() {
|
||||||
var style = '#test { [column = "test\'ing"] { marker-width: 10; } }';
|
var style = '#test { [column = "test\'ing"] { marker-width: 10; } }';
|
||||||
var shader = (new carto.RendererJS({ debug: true })).render(style);
|
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
var layer = shader.getLayers()[0];
|
var layer = shader.getLayers()[0];
|
||||||
var props = layer.getStyle({column: 'test\'ing'}, { 'zoom': 0, 'frame-offset': 10 });
|
var props = layer.getStyle({column: 'test\'ing'}, { 'zoom': 0, 'frame-offset': 10 });
|
||||||
assert(props['marker-width'] === 10);
|
assert(props['marker-width'] === 10);
|
||||||
@ -141,7 +141,7 @@ describe('RenderingJS', function() {
|
|||||||
|
|
||||||
it("should parse styles with filters not supported by dot notation", function() {
|
it("should parse styles with filters not supported by dot notation", function() {
|
||||||
var style = '#test["mapnik::geometry_type"=1] { marker-width: 10; }';
|
var style = '#test["mapnik::geometry_type"=1] { marker-width: 10; }';
|
||||||
var shader = (new carto.RendererJS({ debug: true })).render(style);
|
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
|
||||||
var layer = shader.getLayers()[0];
|
var layer = shader.getLayers()[0];
|
||||||
var props = layer.getStyle({"mapnik::geometry_type": 1}, { 'zoom': 0 });
|
var props = layer.getStyle({"mapnik::geometry_type": 1}, { 'zoom': 0 });
|
||||||
assert.equal(props['marker-width'], 10);
|
assert.equal(props['marker-width'], 10);
|
||||||
@ -155,7 +155,7 @@ describe('RenderingJS', function() {
|
|||||||
' marker-width: ramp([cartodb_id], (#fff, #bbb), jenks);',
|
' marker-width: ramp([cartodb_id], (#fff, #bbb), jenks);',
|
||||||
'}'
|
'}'
|
||||||
].join('\n');
|
].join('\n');
|
||||||
var shader = (new carto.RendererJS({ debug: true })).render(css);
|
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(css);
|
||||||
var layer = shader.getLayers()[0];
|
var layer = shader.getLayers()[0];
|
||||||
var st = layer.shader['marker-width'].style({}, {zoom: 1})
|
var st = layer.shader['marker-width'].style({}, {zoom: 1})
|
||||||
assert.equal(st.name, "ramp")
|
assert.equal(st.name, "ramp")
|
||||||
@ -172,7 +172,7 @@ describe('RenderingJS', function() {
|
|||||||
' marker-width: ramp([cartodb_id], cartocolor(Bold), category(10));',
|
' marker-width: ramp([cartodb_id], cartocolor(Bold), category(10));',
|
||||||
'}'
|
'}'
|
||||||
].join('\n');
|
].join('\n');
|
||||||
var shader = (new carto.RendererJS({ debug: true })).render(css);
|
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(css);
|
||||||
var layer = shader.getLayers()[0];
|
var layer = shader.getLayers()[0];
|
||||||
var st = layer.shader['marker-width'].style({}, {zoom: 1});
|
var st = layer.shader['marker-width'].style({}, {zoom: 1});
|
||||||
assert.equal(st.name, "ramp");
|
assert.equal(st.name, "ramp");
|
||||||
|
Loading…
Reference in New Issue
Block a user