From 495eef2ee433c026f5e00146adee0fa1da3dc4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 9 Apr 2013 08:40:41 -0700 Subject: [PATCH] Fix issue with precision and PathItem#getAverageColor() tests. --- test/lib/helpers.js | 8 ++++---- test/tests/Raster.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/lib/helpers.js b/test/lib/helpers.js index f1a70eec..bc0a1c33 100644 --- a/test/lib/helpers.js +++ b/test/lib/helpers.js @@ -64,10 +64,10 @@ function compareNumbers(number1, number2, message, precision) { Format.number(number2, precision), message); } -function compareArrays(array1, array2, message) { +function compareArrays(array1, array2, message, precision) { function format(array) { return Base.each(array, function(value, index) { - this[index] = Format.number(value); + this[index] = Format.number(value, precision); }, []).toString(); } equals(format(array1), format(array2), message); @@ -85,12 +85,12 @@ function compareRectangles(rect1, rect2, message) { compareNumbers(rect1.height, rect2.height, (message || '') + ' height'); } -function compareColors(color1, color2, message) { +function compareColors(color1, color2, message, precision) { color1 = new Color(color1); color2 = new Color(color2); equals(color1.type, color2.type, (message || '') + ' type'); compareArrays(color1.components, color2.components, - (message || '') + ' components'); + (message || '') + ' components', precision); } function comparePathStyles(style, style2, checkIdentity) { diff --git a/test/tests/Raster.js b/test/tests/Raster.js index 696dec99..32c39d7e 100644 --- a/test/tests/Raster.js +++ b/test/tests/Raster.js @@ -131,7 +131,7 @@ test('Raster#getAverageColor(path)', function() { }); var raster = paper.project.activeLayer.rasterize(); path.scale(0.9); - compareColors(raster.getAverageColor(path), new Color(1, 0, 0)); + compareColors(raster.getAverageColor(path), new Color(1, 0, 0), null, 3); }); test('Raster#getAverageColor(path) with compound path', function() { @@ -153,5 +153,5 @@ test('Raster#getAverageColor(path) with compound path', function() { var raster = paper.project.activeLayer.rasterize(); path.scale(0.9); path2.scale(1.1); - compareColors(raster.getAverageColor(compoundPath), new Color(1, 0, 0)); + compareColors(raster.getAverageColor(compoundPath), new Color(1, 0, 0), null, 3); });