mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
96d97c2aa8
Rather than each tool requesting annotations, and nodes pertaining to selection, Emitted event supplies annotations and nodes to each tool's update method. Using select vs. of traverseLeafNodes for code optimization. Better documentation for updateTools() Removed unneeded code. Change-Id: I7c0baa1cc0f7fb731d6e28b175a76e931e9e2961
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
/**
|
|
* VisualEditor BranchNode tests.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
QUnit.module( 've.BranchNode' );
|
|
|
|
/* Stubs */
|
|
|
|
ve.BranchNodeStub = function VeBranchNodeStub( children ) {
|
|
ve.BranchNode.call( this, children );
|
|
};
|
|
|
|
ve.inheritClass( ve.BranchNodeStub, ve.Node );
|
|
ve.mixinClass( ve.BranchNodeStub, ve.BranchNode );
|
|
|
|
/* Tests */
|
|
|
|
QUnit.test( 'getChildren', 2, function ( assert ) {
|
|
var node1 = new ve.BranchNodeStub(),
|
|
node2 = new ve.BranchNodeStub( [node1] );
|
|
assert.deepEqual( node1.getChildren(), [] );
|
|
assert.deepEqual( node2.getChildren(), [node1] );
|
|
} );
|
|
|
|
QUnit.test( 'indexOf', 4, function ( assert ) {
|
|
var node1 = new ve.BranchNodeStub(),
|
|
node2 = new ve.BranchNodeStub(),
|
|
node3 = new ve.BranchNodeStub(),
|
|
node4 = new ve.BranchNodeStub( [node1, node2, node3] );
|
|
assert.strictEqual( node4.indexOf( null ), -1 );
|
|
assert.strictEqual( node4.indexOf( node1 ), 0 );
|
|
assert.strictEqual( node4.indexOf( node2 ), 1 );
|
|
assert.strictEqual( node4.indexOf( node3 ), 2 );
|
|
} );
|