From f8a9995050418848e5bbf7a2a2baf866938f9d3a Mon Sep 17 00:00:00 2001 From: IagoLast Date: Fri, 28 Jul 2017 12:01:37 +0200 Subject: [PATCH] Add a tdd option into the package.json scripts This option includes a env variable to control the verbosity of the test logs. --- package.json | 1 + test/rendering_js.test.js | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 903b8fe..2e89940 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "scripts": { "pretest": "npm install", "test": "mocha -R spec", + "tdd" : "env HIDE_LOGS=true mocha -w -R spec", "coverage": "istanbul cover ./node_modules/.bin/_mocha && coveralls < ./coverage/lcov.info" } } diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index 2e9977b..b04cd44 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -1,4 +1,4 @@ - +var SHOW_LOGS = (process.env.HIDE_LOGS !== 'true'); var assert = require('assert'); var carto = require('../lib/carto'); describe('RenderingJS', function() { @@ -21,7 +21,7 @@ describe('RenderingJS', function() { ].join('\n'); beforeEach(function() { - shader = (new carto.RendererJS()).render(style); + shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); }); it ("shold render layers", function() { @@ -45,7 +45,7 @@ describe('RenderingJS', function() { it ("shold render variables", function() { var style = '#test { marker-width: [testing]; }'; - shader = (new carto.RendererJS()).render(style); + shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); var layer = shader.getLayers()[0]; var props = layer.getStyle({testing: 2}, { 'zoom': 0, 'frame-offset': 10 }); assert( props['marker-width'] === 2); @@ -53,7 +53,7 @@ describe('RenderingJS', function() { it ("should allow filter based rendering", function() { var style = '#test { marker-width: 10; [zoom = 1] { marker-width: 1; } }'; - shader = (new carto.RendererJS()).render(style); + shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); var layer = shader.getLayers()[0]; var props = layer.getStyle({}, { 'zoom': 0, 'frame-offset': 10 }); assert( props['marker-width'] === 10); @@ -64,7 +64,7 @@ describe('RenderingJS', function() { it ("symbolizers should be in rendering order", function() { var style = '#test { polygon-fill: red; line-color: red; }'; style += '#test2 { line-color: red;polygon-fill: red; line-width: 10; }'; - var shader = (new carto.RendererJS()).render(style); + var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); var layer0 = shader.getLayers()[0]; assert(layer0.getSymbolizers()[0] === 'polygon'); assert(layer0.getSymbolizers()[1] === 'line'); @@ -76,7 +76,7 @@ describe('RenderingJS', 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 shader = (new carto.RendererJS()).render(style); + var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style); var layer0 = shader.getLayers()[0]; 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]]; @@ -106,7 +106,7 @@ describe('RenderingJS', function() { ' [frame-offset = 2] { marker-width: 15; marker-fill-opacity: 0.02;}', '}' ].join('\n'); - var shader = (new carto.RendererJS()).render(css); + var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(css); 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"]; for(var i = 0; i