2012-04-19 21:17:59 +00:00
|
|
|
module( 've.BranchNode' );
|
2012-04-19 21:43:31 +00:00
|
|
|
|
|
|
|
/* Stubs */
|
|
|
|
|
2012-04-19 23:03:59 +00:00
|
|
|
ve.BranchNodeStub = function( children ) {
|
2012-04-19 21:43:31 +00:00
|
|
|
// Inheritance
|
2012-04-19 23:03:59 +00:00
|
|
|
ve.BranchNode.call( this, children );
|
2012-04-19 21:43:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ve.extendClass( ve.BranchNodeStub, ve.BranchNode );
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
2012-04-27 18:03:08 +00:00
|
|
|
test( 'getChildren', 2, function() {
|
2012-04-19 23:03:59 +00:00
|
|
|
var node1 = new ve.BranchNodeStub(),
|
|
|
|
node2 = new ve.BranchNodeStub( [node1] );
|
|
|
|
deepEqual( node1.getChildren(), [] );
|
|
|
|
deepEqual( node2.getChildren(), [node1] );
|
|
|
|
} );
|
|
|
|
|
2012-04-27 18:03:08 +00:00
|
|
|
test( 'indexOf', 4, function() {
|
2012-04-19 23:03:59 +00:00
|
|
|
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 );
|
|
|
|
} );
|