r100721 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100720‎ | r100721 | r100722 >
Date:18:16, 25 October 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added tests for commit and rollback, and fixed some issues in commit and rollback (using static rather than dynamic data for operations functions.
Modified paths:
  • /trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js (modified) (history)
  • /trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js
@@ -498,3 +498,37 @@
499499 'prepareInsertion completes opening elements in inserted content'
500500 );
501501 } );
 502+
 503+test( 'es.DocumentModel.commit, es.DocumentModel.rollback', 2, function() {
 504+ var documentModel = es.DocumentModel.newFromPlainObject( obj );
 505+
 506+ var tx = documentModel.prepareInsertion( 4, ['d'] );
 507+ documentModel.commit( tx );
 508+
 509+ deepEqual(
 510+ documentModel.getData( new es.Range( 0, 6 ) ),
 511+ [
 512+ { 'type': 'paragraph' },
 513+ 'a',
 514+ ['b', { 'type': 'bold', 'hash': '#bold' }],
 515+ ['c', { 'type': 'italic', 'hash': '#italic' }],
 516+ 'd',
 517+ { 'type': '/paragraph' }
 518+ ],
 519+ 'commit applies a transaction to the content'
 520+ );
 521+
 522+ documentModel.rollback( tx );
 523+
 524+ deepEqual(
 525+ documentModel.getData( new es.Range( 0, 5 ) ),
 526+ [
 527+ { 'type': 'paragraph' },
 528+ 'a',
 529+ ['b', { 'type': 'bold', 'hash': '#bold' }],
 530+ ['c', { 'type': 'italic', 'hash': '#italic' }],
 531+ { 'type': '/paragraph' }
 532+ ],
 533+ 'rollback reverses the effect of a transaction on the content'
 534+ );
 535+} );
Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
@@ -817,8 +817,8 @@
818818 };
819819 for ( var i = 0, length = transaction.length; i < length; i++ ) {
820820 var operation = transaction[i];
821 - if ( operation.type in this.operations ) {
822 - this.operations[operation.type].commit.call( state, operation );
 821+ if ( operation.type in es.DocumentModel.operations ) {
 822+ es.DocumentModel.operations[operation.type].commit.call( state, operation );
823823 } else {
824824 throw 'Invalid operation error. Operation type is not supported: ' + operation.type;
825825 }
@@ -842,8 +842,8 @@
843843 };
844844 for ( var i = 0, length = transaction.length; i < length; i++ ) {
845845 var operation = transaction[i];
846 - if ( operation.type in this.operations ) {
847 - this.operations[operation.type].rollback.call( state, operation );
 846+ if ( operation.type in es.DocumentModel.operations ) {
 847+ es.DocumentModel.operations[operation.type].rollback.call( state, operation );
848848 } else {
849849 throw 'Invalid operation error. Operation type is not supported: ' + operation.type;
850850 }

Status & tagging log