Skip to content

Commit

Permalink
Implement more unit tests for PaperScope#settings.insertItems
Browse files Browse the repository at this point in the history
  • Loading branch information
lehni committed Feb 14, 2016
1 parent 55e7689 commit 01fade8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
21 changes: 19 additions & 2 deletions test/tests/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,30 @@ test('Item#applyMatrix', function() {
test('PaperScope#settings.insertItems', function() {
var insertItems = paper.settings.insertItems;
paper.settings.insertItems = true;

var path1, path2;

equals(function() {
return new Path().parent === project.activeLayer;
path1 = new Path();
return path1.parent === project.activeLayer;
}, true);
paper.settings.insertItems = false;

equals(function() {
return new Path().parent === null;
path2 = new Path();
return path2.parent === null;
}, true);

equals(function() {
return project.activeLayer.children.length;
}, 1);

project.activeLayer.addChild(path2);

equals(function() {
return project.activeLayer.children.length;
}, 2);

paper.settings.insertItems = insertItems;
});

Expand Down
16 changes: 8 additions & 8 deletions test/tests/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ test('previousSibling / nextSibling', function() {
return secondLayer.children.length;
}, 2);
equals(function() {
return thirdLayer.nextSibling == path;
return thirdLayer.nextSibling === path;
}, true);
secondLayer.addChild(thirdLayer);
equals(function() {
return thirdLayer.nextSibling == null;
}, true);
return thirdLayer.nextSibling;
}, null);
equals(function() {
return thirdLayer.previousSibling == path;
return thirdLayer.previousSibling === path;
}, true);
equals(function() {
return project.layers.length == 2;
}, true);
return project.layers.length;
}, 2);

firstLayer.addChild(secondLayer);
equals(function() {
return project.layers.length == 1;
}, true);
return project.layers.length;
}, 1);
});

test('insertAbove / insertBelow', function() {
Expand Down

0 comments on commit 01fade8

Please sign in to comment.