From 777cc95dc32a73f74e7a0219c75af3c78b9ea7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 20 May 2011 14:08:17 +0100 Subject: [PATCH] Rename proj -> project in all tests. --- test/lib/helpers.js | 4 +-- test/tests/Item.js | 76 +++++++++++++++++++++---------------------- test/tests/Layer.js | 47 ++++++++++++++++++++++---- test/tests/Project.js | 6 ++-- 4 files changed, 83 insertions(+), 50 deletions(-) diff --git a/test/lib/helpers.js b/test/lib/helpers.js index 99cad69f..b70aba0f 100644 --- a/test/lib/helpers.js +++ b/test/lib/helpers.js @@ -20,9 +20,9 @@ function equals(actual, expected, message) { function test(testName, expected) { return QUnit.test(testName, function() { - var proj = new Project(); + var project = new Project(); expected(); - proj.remove(); + project.remove(); }); } diff --git a/test/tests/Item.js b/test/tests/Item.js index 46d54057..d944dabc 100644 --- a/test/tests/Item.js +++ b/test/tests/Item.js @@ -1,7 +1,7 @@ module('Item'); test('copyTo(project)', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); var secondDoc = new Project(); var copy = path.copyTo(secondDoc); @@ -9,7 +9,7 @@ test('copyTo(project)', function() { return secondDoc.activeLayer.children.indexOf(copy) != -1; }, true); equals(function() { - return proj.activeLayer.children.indexOf(copy) == -1; + return project.activeLayer.children.indexOf(copy) == -1; }, true); equals(function() { return copy != path; @@ -17,7 +17,7 @@ test('copyTo(project)', function() { }); test('copyTo(layer)', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); var layer = new Layer(); @@ -26,16 +26,16 @@ test('copyTo(layer)', function() { return layer.children.indexOf(copy) != -1; }, true); equals(function() { - return proj.layers[0].children.indexOf(copy) == -1; + return project.layers[0].children.indexOf(copy) == -1; }, true); }); test('clone()', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); var copy = path.clone(); equals(function() { - return proj.activeLayer.children.length; + return project.activeLayer.children.length; }, 2); equals(function() { return path != copy; @@ -43,28 +43,28 @@ test('clone()', function() { }); test('appendTop(item)', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); - proj.activeLayer.appendTop(path); + project.activeLayer.appendTop(path); equals(function() { - return proj.activeLayer.children.length; + return project.activeLayer.children.length; }, 1); }); test('item.parent / item.isChild / item.isParent', function() { - var proj = paper.project; + var project = paper.project; var secondDoc = new Project(); var path = new Path(); - proj.activeLayer.appendTop(path); + project.activeLayer.appendTop(path); equals(function() { - return proj.activeLayer.children.indexOf(path) != -1; + return project.activeLayer.children.indexOf(path) != -1; }, true); secondDoc.activeLayer.appendTop(path); equals(function() { - return proj.activeLayer.isChild(path); + return project.activeLayer.isChild(path); }, false); equals(function() { - return path.isParent(proj.activeLayer); + return path.isParent(project.activeLayer); }, false); equals(function() { return secondDoc.activeLayer.isChild(path); @@ -73,7 +73,7 @@ test('item.parent / item.isChild / item.isParent', function() { return path.isParent(secondDoc.activeLayer); }, true); equals(function() { - return proj.activeLayer.children.indexOf(path) == -1; + return project.activeLayer.children.indexOf(path) == -1; }, true); equals(function() { return secondDoc.activeLayer.children.indexOf(path) == 0; @@ -81,39 +81,39 @@ test('item.parent / item.isChild / item.isParent', function() { }); test('item.lastChild / item.firstChild', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); var secondPath = new Path(); equals(function() { - return proj.activeLayer.firstChild == path; + return project.activeLayer.firstChild == path; }, true); equals(function() { - return proj.activeLayer.lastChild == secondPath; + return project.activeLayer.lastChild == secondPath; }, true); }); test('appendBottom(item)', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); var secondPath = new Path(); - proj.activeLayer.appendBottom(secondPath); + project.activeLayer.appendBottom(secondPath); equals(function() { return secondPath.index < path.index; }, true); }); test('moveAbove(item)', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); var secondPath = new Path(); path.moveAbove(secondPath); equals(function() { - return proj.activeLayer.lastChild == path; + return project.activeLayer.lastChild == path; }, true); }); test('moveBelow(item)', function() { - var proj = paper.project; + var project = paper.project; var firstPath = new Path(); var secondPath = new Path(); equals(function() { @@ -126,33 +126,33 @@ test('moveBelow(item)', function() { }); test('isDescendant(item) / isAncestor(item)', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); equals(function() { - return path.isDescendant(proj.activeLayer); + return path.isDescendant(project.activeLayer); }, true); equals(function() { - return proj.activeLayer.isDescendant(path); + return project.activeLayer.isDescendant(path); }, false); equals(function() { - return path.isAncestor(proj.activeLayer); + return path.isAncestor(project.activeLayer); }, false); equals(function() { - return proj.activeLayer.isAncestor(path); + return project.activeLayer.isAncestor(path); }, true); // an item can't be its own descendant: equals(function() { - return proj.activeLayer.isDescendant(proj.activeLayer); + return project.activeLayer.isDescendant(project.activeLayer); }, false); // an item can't be its own ancestor: equals(function() { - return proj.activeLayer.isAncestor(proj.activeLayer); + return project.activeLayer.isAncestor(project.activeLayer); }, false); }); test('isGroupedWith', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); var secondPath = new Path(); var group = new Group([path]); @@ -205,27 +205,27 @@ test('getPreviousSibling() / getNextSibling()', function() { }); test('reverseChildren()', function() { - var proj = paper.project; + var project = paper.project; var path = new Path(); var secondPath = new Path(); var thirdPath = new Path(); equals(function() { - return proj.activeLayer.firstChild == path; + return project.activeLayer.firstChild == path; }, true); - proj.activeLayer.reverseChildren(); + project.activeLayer.reverseChildren(); equals(function() { - return proj.activeLayer.firstChild == path; + return project.activeLayer.firstChild == path; }, false); equals(function() { - return proj.activeLayer.firstChild == thirdPath; + return project.activeLayer.firstChild == thirdPath; }, true); equals(function() { - return proj.activeLayer.lastChild == path; + return project.activeLayer.lastChild == path; }, true); }); test('Check item#project when moving items across projects', function() { - var proj = paper.project; + var project = paper.project; var doc1 = new Project(); var path = new Path(); var group = new Group(); diff --git a/test/tests/Layer.js b/test/tests/Layer.js index 543c2770..e67f6da2 100644 --- a/test/tests/Layer.js +++ b/test/tests/Layer.js @@ -1,8 +1,8 @@ module('Layer'); test('previousSibling / nextSibling', function() { - var proj = paper.project; - var firstLayer = proj.activeLayer; + var project = paper.project; + var firstLayer = project.activeLayer; var secondLayer = new Layer(); equals(function() { return secondLayer.previousSibling == firstLayer; @@ -30,18 +30,18 @@ test('previousSibling / nextSibling', function() { return thirdLayer.previousSibling == path; }, true); equals(function() { - return proj.layers.length == 2; + return project.layers.length == 2; }, true); firstLayer.appendTop(secondLayer); equals(function() { - return proj.layers.length == 1; + return project.layers.length == 1; }, true); }); test('moveAbove / moveBelow', function() { - var proj = paper.project; - var firstLayer = proj.activeLayer; + var project = paper.project; + var firstLayer = project.activeLayer; var secondLayer = new Layer(); secondLayer.moveBelow(firstLayer); equals(function() { @@ -64,6 +64,39 @@ test('moveAbove / moveBelow', function() { }, true); // There should now only be one layer left: equals(function() { - return proj.layers.length; + return project.layers.length; + }, 1); +}); + +test('appendTop / appendBottom / nesting', function() { + var project = paper.project; + var firstLayer = project.activeLayer; + var secondLayer = new Layer(); + // There should be two layers now in project.layers + equals(function() { + return project.layers.length; + }, 1); + firstLayer.appendTop(secondLayer); + equals(function() { + return secondLayer.parent == firstLayer; + }, true); + equals(function() { + return secondLayer.nextSibling == firstLayer; + }, true); + + var path = new Path(); + firstLayer.appendTop(path); + + // move the layer above the path, inside the firstLayer: + secondLayer.moveAbove(path); + equals(function() { + return secondLayer.previousSibling == path; + }, true); + equals(function() { + return secondLayer.parent == firstLayer; + }, true); + // There should now only be one layer left: + equals(function() { + return project.layers.length; }, 1); }); \ No newline at end of file diff --git a/test/tests/Project.js b/test/tests/Project.js index c088aca5..f4222b06 100644 --- a/test/tests/Project.js +++ b/test/tests/Project.js @@ -1,12 +1,12 @@ module('Project'); test('activate()', function() { - var proj = new Project(); + var project = new Project(); var secondDoc = new Project(); - proj.activate(); + project.activate(); var path = new Path(); equals(function() { - return proj.activeLayer.children[0] == path; + return project.activeLayer.children[0] == path; }, true); equals(function() { return secondDoc.activeLayer.children.length == 0;