From dca049c6ab948621bb75e06b14cef6cd781db1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 23 Jun 2013 18:18:49 -0700 Subject: [PATCH] Implement failing test for hit-testing guides. --- test/tests/HitResult.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/tests/HitResult.js b/test/tests/HitResult.js index 57de35df..d44e674b 100644 --- a/test/tests/HitResult.js +++ b/test/tests/HitResult.js @@ -565,4 +565,35 @@ test('Hit testing invisible items.', function() { }, true); }); +test('Hit testing guides.', function() { + var point = new Point(0, 0); + var circle1 = new Path.Circle({ + center: point.subtract([25, 0]), + radius: 50, + fillColor: 'red' + }); + var circle2 = new Path.Circle({ + center: point.add([25, 0]), + radius: 50, + fillColor: 'blue' + }); + + var strokePoint = circle2.bounds.rightCenter; + + equals(function() { + return paper.project.hitTest(strokePoint).item === circle2; + }, true); + + circle2.guide = true; + + equals(function() { + var result = paper.project.hitTest(strokePoint, { guides: true }); + return result && result.item === circle1; + }, true); + + equals(function() { + return paper.project.hitTest(point).item === circle1; + }, true); +}); + // TODO: project.hitTest(point, {type: AnItemType}); \ No newline at end of file