mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Added tests for getOffsetFromNode
Change-Id: I4dc06e9ea3b634fbd5034df721162098441ea368
This commit is contained in:
parent
619f10108c
commit
71f36aa52b
|
@ -7,8 +7,15 @@ ve.dm.BranchNodeStub = function( children ) {
|
|||
ve.dm.BranchNode.call( this, 'branch-stub', children );
|
||||
};
|
||||
|
||||
ve.dm.BranchNodeStub.rules = {
|
||||
'canHaveChildren': true,
|
||||
'canHaveGrandchildren': true
|
||||
};
|
||||
|
||||
ve.extendClass( ve.dm.BranchNodeStub, ve.dm.BranchNode );
|
||||
|
||||
ve.dm.factory.register( 'branch-stub', ve.dm.BranchNodeStub );
|
||||
|
||||
/* Tests */
|
||||
|
||||
test( 'setRoot', 3, function() {
|
||||
|
@ -89,3 +96,14 @@ test( 'splice', 9, function() {
|
|||
deepEqual( node4.splice( 1, 1, node3 ), [node2] );
|
||||
deepEqual( node4.getChildren(), [node1, node3] );
|
||||
} );
|
||||
|
||||
test( 'getOffsetFromNode', 4, function() {
|
||||
var node1 = new ve.dm.BranchNodeStub(),
|
||||
node2 = new ve.dm.BranchNodeStub(),
|
||||
node3 = new ve.dm.BranchNodeStub( [node1, node2] ),
|
||||
node4 = new ve.dm.BranchNodeStub( [node3] );
|
||||
strictEqual( node4.getOffsetFromNode( node1 ), 1 );
|
||||
strictEqual( node4.getOffsetFromNode( node2 ), 3 );
|
||||
strictEqual( node4.getOffsetFromNode( node3 ), 0 );
|
||||
strictEqual( node4.getOffsetFromNode( node4 ), 0 );
|
||||
} );
|
||||
|
|
|
@ -7,6 +7,13 @@ ve.dm.LeafNodeStub = function() {
|
|||
ve.dm.LeafNode.call( this, 'leaf-stub' );
|
||||
};
|
||||
|
||||
ve.dm.LeafNodeStub.rules = {
|
||||
'canHaveChildren': false,
|
||||
'canHaveGrandchildren': false
|
||||
};
|
||||
|
||||
ve.extendClass( ve.dm.LeafNodeStub, ve.dm.LeafNode );
|
||||
|
||||
ve.dm.factory.register( 'leaf-stub', ve.dm.LeafNodeStub );
|
||||
|
||||
/* Tests */
|
||||
|
|
Loading…
Reference in a new issue