Implement more unit tests for PaperScope#settings.insertItems

This commit is contained in:
Jürg Lehni 2016-02-14 22:04:40 +01:00
parent 55e7689186
commit 01fade8c08
2 changed files with 28 additions and 11 deletions

View file

@ -759,13 +759,30 @@ test('Item#applyMatrix', function() {
test('PaperScope#settings.insertItems', function() { test('PaperScope#settings.insertItems', function() {
var insertItems = paper.settings.insertItems; var insertItems = paper.settings.insertItems;
paper.settings.insertItems = true; paper.settings.insertItems = true;
var path1, path2;
equals(function() { equals(function() {
return new Path().parent === project.activeLayer; path1 = new Path();
return path1.parent === project.activeLayer;
}, true); }, true);
paper.settings.insertItems = false; paper.settings.insertItems = false;
equals(function() { equals(function() {
return new Path().parent === null; path2 = new Path();
return path2.parent === null;
}, true); }, 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; paper.settings.insertItems = insertItems;
}); });

View file

@ -32,23 +32,23 @@ test('previousSibling / nextSibling', function() {
return secondLayer.children.length; return secondLayer.children.length;
}, 2); }, 2);
equals(function() { equals(function() {
return thirdLayer.nextSibling == path; return thirdLayer.nextSibling === path;
}, true); }, true);
secondLayer.addChild(thirdLayer); secondLayer.addChild(thirdLayer);
equals(function() { equals(function() {
return thirdLayer.nextSibling == null; return thirdLayer.nextSibling;
}, null);
equals(function() {
return thirdLayer.previousSibling === path;
}, true); }, true);
equals(function() { equals(function() {
return thirdLayer.previousSibling == path; return project.layers.length;
}, true); }, 2);
equals(function() {
return project.layers.length == 2;
}, true);
firstLayer.addChild(secondLayer); firstLayer.addChild(secondLayer);
equals(function() { equals(function() {
return project.layers.length == 1; return project.layers.length;
}, true); }, 1);
}); });
test('insertAbove / insertBelow', function() { test('insertAbove / insertBelow', function() {