From c12f7c4a64e1df1688da690f41eeb82e27531b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 29 Dec 2016 10:55:53 +0100 Subject: [PATCH] Start implementing unit tests for PathItem#compare() --- test/tests/PathItem.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/tests/PathItem.js b/test/tests/PathItem.js index e3bf332c..6ff1ae79 100644 --- a/test/tests/PathItem.js +++ b/test/tests/PathItem.js @@ -118,3 +118,36 @@ test('PathItem#create() with SVG path-data (#1101)', function() { equals(path, PathItem.create(expected[i]), 'data[' + i + ']'); }); }); + +test('PathItem#compare()', function() { + var empty = new Path(); + var circle = new Path.Circle({ + point: [100, 100], + radius: 100 + }); + var square = new Path.Rectangle({ + point: [0, 0], + size: [100, 100] + }); + equals(function() { + return square.compare(null); + }, false, 'Comparing with an invalid item should return false.'); + equals(function() { + return square.compare(empty); + }, false, 'Comparing a square with an empty path should return false.'); + equals(function() { + return square.compare(circle); + }, false, 'Comparing a square with a circle should return false.'); + equals(function() { + return square.compare(square.clone()); + }, true, 'Comparing a square with its clone should return true.'); + equals(function() { + return circle.compare(circle.clone()); + }, true, 'Comparing a circle with its clone should return true.'); + equals(function() { + return square.compare(square.clone().rotate(90)); + }, true, 'Comparing a square with its rotated clone should return true.'); + equals(function() { + return circle.compare(circle.clone().rotate(90)); + }, true, 'Comparing a circle with its rotated clone should return true.'); +});