refactor findOne method

This commit is contained in:
Adam L
2018-03-26 00:25:24 -07:00
parent 514e60122b
commit 2466ea61b0
3 changed files with 36 additions and 15 deletions

View File

@@ -291,7 +291,7 @@ suite('Container', function() {
});
// ======================================================
test('select shape by id and name with findOne', function() {
test('select shape with findOne', function() {
var stage = addStage();
var layer = new Konva.Layer({
id: 'myLayer'
@@ -330,6 +330,10 @@ suite('Container', function() {
assert.equal(node, undefined, 'node should be undefined');
node = stage.findOne('#myLayer');
assert.equal(node, layer, 'node type should be Layer');
node = stage.findOne(function(node) {
return node.getType() === 'Shape';
});
assert.equal(node, circle, 'findOne should work with functions');
});
// ======================================================