mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 16:44:51 +00:00
2cee2adb6d
* Added support for asking if a given node type can have children or grandchildren and what types of nodes can be it's parent or child * Removed canHaveChildren methods from leaf and branch nodes and converted use of them to depend on factory to read static rules from constructor lookup by type Change-Id: I9769f95647066576416bacb791c4b68dd0285b35
31 lines
793 B
JavaScript
31 lines
793 B
JavaScript
module( 've.BranchNode' );
|
|
|
|
/* Stubs */
|
|
|
|
ve.BranchNodeStub = function( children ) {
|
|
// Inheritance
|
|
ve.BranchNode.call( this, children );
|
|
};
|
|
|
|
ve.extendClass( ve.BranchNodeStub, ve.BranchNode );
|
|
|
|
/* Tests */
|
|
|
|
test( 'getChildren', 2, function() {
|
|
var node1 = new ve.BranchNodeStub(),
|
|
node2 = new ve.BranchNodeStub( [node1] );
|
|
deepEqual( node1.getChildren(), [] );
|
|
deepEqual( node2.getChildren(), [node1] );
|
|
} );
|
|
|
|
test( 'indexOf', 4, function() {
|
|
var node1 = new ve.BranchNodeStub(),
|
|
node2 = new ve.BranchNodeStub(),
|
|
node3 = new ve.BranchNodeStub(),
|
|
node4 = new ve.BranchNodeStub( [node1, node2, node3] );
|
|
strictEqual( node4.indexOf( null ), -1 );
|
|
strictEqual( node4.indexOf( node1 ), 0 );
|
|
strictEqual( node4.indexOf( node2 ), 1 );
|
|
strictEqual( node4.indexOf( node3 ), 2 );
|
|
} );
|