mediawiki-extensions-Visual.../tests/ve2/ve.BranchNode.test.js
Trevor Parscal 3d6391419d Added more nodes and removed canHave[Grandc|C]hildren methods
Replacing them with static members on each node type

Change-Id: I455debf880bef4e280eea072364f5f57308ec2b1
2012-04-20 16:34:47 -07:00

31 lines
813 B
JavaScript

module( 've.BranchNode' );
/* Stubs */
ve.BranchNodeStub = function( children ) {
// Inheritance
ve.BranchNode.call( this, children );
};
ve.extendClass( ve.BranchNodeStub, ve.BranchNode );
/* Tests */
test( 'prototype.getChildren', 2, function() {
var node1 = new ve.BranchNodeStub(),
node2 = new ve.BranchNodeStub( [node1] );
deepEqual( node1.getChildren(), [] );
deepEqual( node2.getChildren(), [node1] );
} );
test( 'prototype.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 );
} );