From f010850f0a4eb8a24ba7c2e1e118a604ae1d10fd Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Tue, 13 Mar 2012 14:54:23 +0100 Subject: [PATCH] Add failing tests for Item#moveAbove(item) and Item#moveBelow(item) --- test/tests/Item_Order.js | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/tests/Item_Order.js b/test/tests/Item_Order.js index 42f1449f..23065984 100644 --- a/test/tests/Item_Order.js +++ b/test/tests/Item_Order.js @@ -57,3 +57,44 @@ test('Item Order', function() { return group.isBelow(circle); }, false); }); + +test('Item#moveAbove(item) / Item#moveBelow(item)', function() { + var item0, item1, item2; + var testMove = function(command, indexes) { + paper.project.activeLayer.remove(); + new Layer(); + item0 = new Group(); + item1 = new Group(); + item2 = new Group(); + command(); + equals(function() { + return item0.index; + }, indexes[0]); + equals(function() { + return item1.index; + }, indexes[1]); + equals(function() { + return item2.index; + }, indexes[2]); + } + + testMove(function() { item0.moveBelow(item0) }, [0,1,2]); + testMove(function() { item0.moveBelow(item1) }, [0,1,2]); + testMove(function() { item0.moveBelow(item2) }, [1,0,2]); + testMove(function() { item1.moveBelow(item0) }, [1,0,2]); + testMove(function() { item1.moveBelow(item1) }, [0,1,2]); + testMove(function() { item1.moveBelow(item2) }, [0,1,2]); + testMove(function() { item2.moveBelow(item0) }, [2,0,1]); + testMove(function() { item2.moveBelow(item1) }, [0,2,1]); + testMove(function() { item2.moveBelow(item2) }, [0,1,2]); + + testMove(function() { item0.moveAbove(item0) }, [0,1,2]); + testMove(function() { item0.moveAbove(item1) }, [1,0,2]); + testMove(function() { item0.moveAbove(item2) }, [1,2,0]); + testMove(function() { item1.moveAbove(item0) }, [0,1,2]); + testMove(function() { item1.moveAbove(item1) }, [0,1,2]); + testMove(function() { item1.moveAbove(item2) }, [0,2,1]); + testMove(function() { item2.moveAbove(item0) }, [0,2,1]); + testMove(function() { item2.moveAbove(item1) }, [0,1,2]); + testMove(function() { item2.moveAbove(item2) }, [0,1,2]); +});