Added additional test to rebuildNodes, now testing rebuilding after a change

Change-Id: I669457389bf742c100dec5205b972f6d1e14ef44
This commit is contained in:
Trevor Parscal 2012-05-07 16:25:39 -07:00
parent 811110d7c6
commit 4bae026190

View file

@ -11,7 +11,7 @@ test( 'getOuterLength', 1, function() {
); );
} ); } );
test( 'rebuildNodes', 114, function() { test( 'rebuildNodes', function() {
var doc = new ve.dm.Document( ve.dm.example.data ), var doc = new ve.dm.Document( ve.dm.example.data ),
documentNode = doc.getDocumentNode(); documentNode = doc.getDocumentNode();
@ -19,6 +19,17 @@ test( 'rebuildNodes', 114, function() {
doc.rebuildNodes( documentNode, 1, 1, 5, 30 ); doc.rebuildNodes( documentNode, 1, 1, 5, 30 );
// Test count: ( ( 4 tests x 21 branch nodes ) + ( 3 tests x 10 leaf nodes ) ) = 114 // Test count: ( ( 4 tests x 21 branch nodes ) + ( 3 tests x 10 leaf nodes ) ) = 114
ve.dm.example.nodeTreeEqual( documentNode, ve.dm.example.tree ); ve.dm.example.nodeTreeEqual( documentNode, ve.dm.example.tree );
// Create a copy of the example tree
var tree = new ve.dm.DocumentNode( ve.dm.example.tree.getChildren() );
// Remove table from linear model
doc.data.splice( 5, 30, { 'type': 'paragraph' }, 'a', 'b', 'c', { 'type': '/paragraph' } );
// Remove table from tree model
tree.splice( 1, 1, new ve.dm.ParagraphNode( [new ve.dm.TextNode( 3 )] ) );
// Rebuild with changes
doc.rebuildNodes( documentNode, 1, 1, 5, 5 );
// Test count:
ve.dm.example.nodeTreeEqual( documentNode, tree );
} ); } );
test( 'selectNodes', 14, function() { test( 'selectNodes', 14, function() {