http://www.mediawiki.org/wiki/Special:Code/MediaWiki/100721

Revision: 100721
Author:   tparscal
Date:     2011-10-25 18:16:41 +0000 (Tue, 25 Oct 2011)
Log Message:
-----------
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
    trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js

Modified: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
===================================================================
--- trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js   2011-10-25 
18:14:30 UTC (rev 100720)
+++ trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js   2011-10-25 
18:16:41 UTC (rev 100721)
@@ -817,8 +817,8 @@
        };
        for ( var i = 0, length = transaction.length; i < length; i++ ) {
                var operation = transaction[i];
-               if ( operation.type in this.operations ) {
-                       this.operations[operation.type].commit.call( state, 
operation );
+               if ( operation.type in es.DocumentModel.operations ) {
+                       
es.DocumentModel.operations[operation.type].commit.call( state, operation );
                } else {
                        throw 'Invalid operation error. Operation type is not 
supported: ' + operation.type;
                }
@@ -842,8 +842,8 @@
        };
        for ( var i = 0, length = transaction.length; i < length; i++ ) {
                var operation = transaction[i];
-               if ( operation.type in this.operations ) {
-                       this.operations[operation.type].rollback.call( state, 
operation );
+               if ( operation.type in es.DocumentModel.operations ) {
+                       
es.DocumentModel.operations[operation.type].rollback.call( state, operation );
                } else {
                        throw 'Invalid operation error. Operation type is not 
supported: ' + operation.type;
                }

Modified: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js
===================================================================
--- trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js   2011-10-25 
18:14:30 UTC (rev 100720)
+++ trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js   2011-10-25 
18:16:41 UTC (rev 100721)
@@ -498,3 +498,37 @@
                'prepareInsertion completes opening elements in inserted 
content'
        );
 } );
+
+test( 'es.DocumentModel.commit, es.DocumentModel.rollback', 2, function() {
+       var documentModel = es.DocumentModel.newFromPlainObject( obj );
+
+       var tx = documentModel.prepareInsertion( 4, ['d'] );
+       documentModel.commit( tx );
+
+       deepEqual(
+               documentModel.getData( new es.Range( 0, 6 ) ),
+               [
+                       { 'type': 'paragraph' },
+                       'a',
+                       ['b', { 'type': 'bold', 'hash': '#bold' }],
+                       ['c', { 'type': 'italic', 'hash': '#italic' }],
+                       'd',
+                       { 'type': '/paragraph' }
+               ],
+               'commit applies a transaction to the content'
+       );
+
+       documentModel.rollback( tx );
+
+       deepEqual(
+               documentModel.getData( new es.Range( 0, 5 ) ),
+               [
+                       { 'type': 'paragraph' },
+                       'a',
+                       ['b', { 'type': 'bold', 'hash': '#bold' }],
+                       ['c', { 'type': 'italic', 'hash': '#italic' }],
+                       { 'type': '/paragraph' }
+               ],
+               'rollback reverses the effect of a transaction on the content'
+       );
+} );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to