From 4bae0261903ef32249abdf4c1009d2e2d38c2670 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Mon, 7 May 2012 16:25:39 -0700 Subject: [PATCH] Added additional test to rebuildNodes, now testing rebuilding after a change Change-Id: I669457389bf742c100dec5205b972f6d1e14ef44 --- tests/ve2/dm/ve.dm.Document.test.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/ve2/dm/ve.dm.Document.test.js b/tests/ve2/dm/ve.dm.Document.test.js index 38813ea4af..ee67d4f83d 100644 --- a/tests/ve2/dm/ve.dm.Document.test.js +++ b/tests/ve2/dm/ve.dm.Document.test.js @@ -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 ), documentNode = doc.getDocumentNode(); @@ -19,6 +19,17 @@ test( 'rebuildNodes', 114, function() { doc.rebuildNodes( documentNode, 1, 1, 5, 30 ); // Test count: ( ( 4 tests x 21 branch nodes ) + ( 3 tests x 10 leaf nodes ) ) = 114 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() {