From b512532d23567dbeb62cac0b349c917d40a19721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 11 Jun 2013 13:53:48 -0700 Subject: [PATCH] Improve compareColors() helper. --- test/lib/helpers.js | 14 +++++++++----- test/tests/Style.js | 4 +--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/lib/helpers.js b/test/lib/helpers.js index cbf3b812..ee6b0fb0 100644 --- a/test/lib/helpers.js +++ b/test/lib/helpers.js @@ -103,11 +103,15 @@ function compareRectangles(rect1, rect2, 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', precision); + color1 = color1 && new Color(color1); + color2 = color2 && new Color(color2); + if (color1 && color2) { + equals(color1.type, color2.type, (message || '') + ' type'); + compareArrays(color1.components, color2.components, + (message || '') + ' components', precision); + } else { + equals(color1, color2, message); + } } function compareStyles(style, style2, checkIdentity) { diff --git a/test/tests/Style.js b/test/tests/Style.js index a39dfc37..574d4266 100644 --- a/test/tests/Style.js +++ b/test/tests/Style.js @@ -161,9 +161,7 @@ test('setting group styles 2', function() { // By appending a path with a different fillcolor, // the group's fillColor should return undefined: - equals(function() { - return group.fillColor; - }, undefined); + equals(group.fillColor, undefined, 'group.fillColor'); // But, both paths have a red strokeColor, so: compareColors(group.strokeColor, 'red', 'group.strokeColor');