Clean up Layer unit tests a bit.

This commit is contained in:
Jürg Lehni 2016-08-07 15:58:54 +02:00
parent 0396446c4c
commit 7a63afc769

View file

@ -12,7 +12,7 @@
QUnit.module('Layer'); QUnit.module('Layer');
test('previousSibling / nextSibling', function() { test('#previousSibling / #nextSibling', function() {
var project = paper.project; var project = paper.project;
var firstLayer = project.activeLayer; var firstLayer = project.activeLayer;
var secondLayer = new Layer(); var secondLayer = new Layer();
@ -51,7 +51,7 @@ test('previousSibling / nextSibling', function() {
}, 1); }, 1);
}); });
test('insertAbove / insertBelow', function() { test('#insertAbove() / #insertBelow()', function() {
var project = paper.project; var project = paper.project;
var firstLayer = project.activeLayer; var firstLayer = project.activeLayer;
firstLayer.name = 'first'; firstLayer.name = 'first';
@ -94,7 +94,7 @@ test('insertAbove / insertBelow', function() {
}, 2); }, 2);
}); });
test('addChild / appendBottom / nesting', function() { test('#addChild() / #insertBelow() with nesting', function() {
var project = paper.project; var project = paper.project;
var firstLayer = project.activeLayer; var firstLayer = project.activeLayer;
var secondLayer = new Layer(); var secondLayer = new Layer();
@ -126,16 +126,16 @@ test('addChild / appendBottom / nesting', function() {
}, true); }, true);
}); });
test('remove', function(){ test('#remove() with named layers', function(){
var layer1 = new Layer({name: 'test-layer'}); var name = 'my layer';
var layer2 = new Layer({name: 'test-layer'}); var layer1 = new Layer({name: name });
var layer2 = new Layer({name: name });
var removeCount = 0; var removeCount = 0;
while (project.layers['test-layer']) { while (project.layers[name]) {
project.layers['test-layer'].remove(); project.layers[name].remove();
++removeCount; if (++removeCount > 2)
if (removeCount > 2) break; break;
} }
equals(function(){ equals(removeCount, 2,
return removeCount; 'project.layers[name].remove(); should be called twice');
}, 2);
}); });