r113506 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113505‎ | r113506 | r113507 >
Date:19:38, 9 March 2012
Author:tparscal
Status:deferred
Tags:
Comment:
Added test for ve.dm.DocumentSynchronizer that exercises multi-action synchronizations
Modified paths:
  • /trunk/extensions/VisualEditor/tests/ve/ve.dm.DocumentSynchronizer.test.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/ve/ve.dm.DocumentSynchronizer.test.js
@@ -1,6 +1,6 @@
22 module( 've/dm' );
33
4 -test( 've.dm.DocumentSynchronizer', 9, function() {
 4+test( 've.dm.DocumentSynchronizer', 10, function() {
55 var tests = {
66 // Test 1
77 'resize actions adjust node lengths': {
@@ -141,6 +141,34 @@
142142 return model.getChildren()[1].getContentData();
143143 },
144144 'expected': ['x']
 145+ },
 146+ // Test 10
 147+ 'multiple actions can be synchronized together': {
 148+ 'actual': function( sync ) {
 149+ var model = sync.getModel(),
 150+ data = [{ 'type': 'paragraph' }, 'x', { 'type': '/paragraph' }],
 151+ node = ve.dm.DocumentNode.createNodesFromData( data )[0];
 152+ // Delete bold "b" from first paragraph
 153+ model.data.splice( 2, 1 );
 154+ // Push resize action
 155+ sync.pushAction( 'resize', model.getChildren()[0], 0, -1 );
 156+ // Delete the first paragraph (offset adjusted for previous action)
 157+ model.data.splice( 30, 3 );
 158+ // Push deletion action (note: using original offset)
 159+ sync.pushAction( 'delete', model.getChildren()[2], 31 );
 160+ // Insert element after last paragraph
 161+ ve.insertIntoArray( model.data, 30, data );
 162+ // Push insertion action (note: using original offset)
 163+ sync.pushAction( 'insert', node, 34 );
 164+ // Sync
 165+ sync.synchronize();
 166+ return [
 167+ model.getChildren()[0].getContentLength(),
 168+ model.getChildren().length,
 169+ model.getChildren()[2].getContentData()
 170+ ];
 171+ },
 172+ 'expected': [2, 3, ['x']]
145173 }
146174 };
147175

Status & tagging log