r113690 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113689‎ | r113690 | r113691 >
Date:00:14, 13 March 2012
Author:catrope
Status:ok
Tags:
Comment:
Add tests for list split tree sync
Modified paths:
  • /trunk/extensions/VisualEditor/tests/ve/ve.dm.TransactionProcessor.test.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/ve/ve.dm.TransactionProcessor.test.js
@@ -1,6 +1,6 @@
22 module( 've/dm' );
33
4 -test( 've.dm.TransactionProcessor', 39, function() {
 4+test( 've.dm.TransactionProcessor', 47, function() {
55 var documentModel = ve.dm.DocumentNode.newFromPlainObject( veTest.obj );
66
77 // FIXME: These tests shouldn't use prepareFoo() because those functions
@@ -366,6 +366,55 @@
367367 );
368368
369369 // Test 31
 370+ deepEqual(
 371+ documentModel.children[1].children[0].children[0].children.length, 3,
 372+ 'commit keeps model tree up to date with list split (number of children)'
 373+ );
 374+
 375+ // Test 32
 376+ deepEqual(
 377+ documentModel.children[1].children[0].children[0].children[1].getElementType(), 'list',
 378+ 'commit keeps model tree up to date with list split (first list type)'
 379+ );
 380+
 381+ // Test 33
 382+ deepEqual(
 383+ documentModel.children[1].children[0].children[0].children[2].getElementType(), 'list',
 384+ 'commit keeps model tree up to date with list split (second list type)'
 385+ );
 386+
 387+ // Test 34
 388+ deepEqual(
 389+ documentModel.children[1].children[0].children[0].children[1].getContentData(),
 390+ [
 391+ { 'type': 'listItem', 'attributes': { 'styles': ['bullet'] } },
 392+ { 'type': 'paragraph' },
 393+ 'e',
 394+ { 'type': '/paragraph' },
 395+ { 'type': '/listItem' }
 396+ ],
 397+ 'commit keeps model tree up to date with list split (first list content)'
 398+ );
 399+
 400+ // Test 35
 401+ deepEqual(
 402+ documentModel.children[1].children[0].children[0].children[2].getContentData(),
 403+ [
 404+ { 'type': 'listItem', 'attributes': { 'styles': ['bullet', 'bullet'] } },
 405+ { 'type': 'paragraph' },
 406+ 'f',
 407+ { 'type': '/paragraph' },
 408+ { 'type': '/listItem' },
 409+ { 'type': 'listItem', 'attributes': { 'styles': ['number'] } },
 410+ { 'type': 'paragraph' },
 411+ 'g',
 412+ { 'type': '/paragraph' },
 413+ { 'type': '/listItem' }
 414+ ],
 415+ 'commit keeps model tree up to date with list split (second list content)'
 416+ );
 417+
 418+ // Test 36
370419 ve.dm.TransactionProcessor.rollback( documentModel, listSplit );
371420 deepEqual(
372421 documentModel.getData( new ve.Range( 15, 19 ) ),
@@ -378,10 +427,45 @@
379428 'rollback reverses list split'
380429 );
381430
 431+ // Test 37
 432+ deepEqual(
 433+ documentModel.children[1].children[0].children[0].children.length, 2,
 434+ 'rollback keeps model tree up to date with list split (number of children)'
 435+ );
382436
 437+ // Test 38
 438+ deepEqual(
 439+ documentModel.children[1].children[0].children[0].children[1].getElementType(), 'list',
 440+ 'rollback keeps model tree up to date with list split (first list type)'
 441+ );
 442+
 443+ // Test 39
 444+ deepEqual(
 445+ documentModel.children[1].children[0].children[0].children[1].getContentData(),
 446+ [
 447+ { 'type': 'listItem', 'attributes': { 'styles': ['bullet'] } },
 448+ { 'type': 'paragraph' },
 449+ 'e',
 450+ { 'type': '/paragraph' },
 451+ { 'type': '/listItem' },
 452+ { 'type': 'listItem', 'attributes': { 'styles': ['bullet', 'bullet'] } },
 453+ { 'type': 'paragraph' },
 454+ 'f',
 455+ { 'type': '/paragraph' },
 456+ { 'type': '/listItem' },
 457+ { 'type': 'listItem', 'attributes': { 'styles': ['number'] } },
 458+ { 'type': 'paragraph' },
 459+ 'g',
 460+ { 'type': '/paragraph' },
 461+ { 'type': '/listItem' }
 462+ ],
 463+ 'rollback keeps model tree up to date with list split (first list content)'
 464+ );
 465+
 466+
383467 var contentReplacement = documentModel.prepareContentReplacement( new ve.Range( 32, 33 ), [ 'i', 'j', 'k' ] );
384468
385 - // Test 32
 469+ // Test 40
386470 ve.dm.TransactionProcessor.commit( documentModel, contentReplacement );
387471 deepEqual(
388472 documentModel.getData( new ve.Range( 31, 36 ) ),
@@ -393,7 +477,7 @@
394478 'replacement replaces content'
395479 );
396480
397 - // Test 33
 481+ // Test 41
398482 ve.dm.TransactionProcessor.rollback( documentModel, contentReplacement );
399483 deepEqual(
400484 documentModel.getData( new ve.Range( 31, 34 ) ),
@@ -407,7 +491,7 @@
408492
409493 var paragraphToHeading = documentModel.prepareWrap( new ve.Range( 1, 4 ), [ { 'type': 'paragraph' } ], [ { 'type': 'heading', 'level': 2 } ], [], [] );
410494
411 - // Test 34
 495+ // Test 42
412496 ve.dm.TransactionProcessor.commit( documentModel, paragraphToHeading );
413497 deepEqual(
414498 documentModel.getData( new ve.Range( 0, 5 ) ),
@@ -421,7 +505,7 @@
422506 'changing paragraph to heading'
423507 );
424508
425 - // Test 35
 509+ // Test 43
426510 ve.dm.TransactionProcessor.rollback( documentModel, paragraphToHeading );
427511 deepEqual(
428512 documentModel.getData( new ve.Range( 0, 5 ) ),
@@ -437,7 +521,7 @@
438522
439523 var unwrapList = documentModel.prepareWrap( new ve.Range( 12, 27 ), [ { 'type': 'list' } ], [] , [ { 'type': 'listItem' } ], [] );
440524
441 - // Test 36
 525+ // Test 44
442526 ve.dm.TransactionProcessor.commit( documentModel, unwrapList );
443527 deepEqual(
444528 documentModel.getData( new ve.Range( 7, 21 ) ),
@@ -460,7 +544,7 @@
461545 'unwrapping the list produces a cell with four adjacent paragraphs'
462546 );
463547
464 - // Test 37
 548+ // Test 45
465549 ve.dm.TransactionProcessor.rollback( documentModel, unwrapList );
466550 deepEqual(
467551 documentModel.getData( new ve.Range( 7, 29 ) ),
@@ -494,7 +578,7 @@
495579 var replaceTable = documentModel.prepareWrap( new ve.Range( 8, 28 ), [ { 'type': 'table' }, { 'type': 'tableRow' }, { 'type': 'tableCell' } ],
496580 [ { 'type': 'list' }, { 'type': 'listItem' } ], [], [] );
497581
498 - // Test 38
 582+ // Test 46
499583 ve.dm.TransactionProcessor.commit( documentModel, replaceTable );
500584 deepEqual(
501585 documentModel.getData( new ve.Range( 5, 30 ) ),
@@ -528,7 +612,7 @@
529613 'replacing a table with the list reverses the order of the closing tags correctly'
530614 );
531615
532 - // Test 39
 616+ // Test 47
533617 ve.dm.TransactionProcessor.rollback( documentModel, replaceTable );
534618 deepEqual(
535619 documentModel.getData( new ve.Range( 5, 32 ) ),

Status & tagging log