r103356 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103355‎ | r103356 | r103357 >
Date:19:07, 16 November 2011
Author:catrope
Status:deferred
Tags:
Comment:
Add test cases to illustrate the breakage in r103271
Modified paths:
  • /trunk/extensions/VisualEditor/tests/es/es.DocumentModel.test.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/es/es.DocumentModel.test.js
@@ -301,7 +301,7 @@
302302 );
303303 } );
304304
305 -test( 'es.DocumentModel.prepareRemoval', 5, function() {
 305+test( 'es.DocumentModel.prepareRemoval', 8, function() {
306306 var documentModel = es.DocumentModel.newFromPlainObject( esTest.obj );
307307
308308 // Test 1
@@ -409,6 +409,106 @@
410410 ],
411411 'prepareRemoval strips and drops correctly when working across structural nodes'
412412 );
 413+
 414+ // Test 6
 415+ deepEqual(
 416+ documentModel.prepareRemoval( new es.Range( 3, 25 ) ).getOperations(),
 417+ [
 418+ { 'type': 'retain', 'length': 3 },
 419+ {
 420+ 'type': 'remove',
 421+ 'data': [['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }]]
 422+ },
 423+ { 'type': 'retain', 'length': 4 },
 424+ {
 425+ 'type': 'remove',
 426+ 'data': [{ 'type': 'paragraph' }, 'd', { 'type': '/paragraph' }]
 427+ },
 428+ { 'type': 'retain', 'length': 1 },
 429+ {
 430+ 'type': 'remove',
 431+ 'data': [
 432+ { 'type': 'listItem', 'attributes': { 'styles': ['bullet'] } },
 433+ { 'type': 'paragraph' },
 434+ 'e',
 435+ { 'type': '/paragraph' },
 436+ { 'type': '/listItem' },
 437+ { 'type': 'listItem', 'attributes': { 'styles': ['bullet', 'bullet'] } },
 438+ { 'type': 'paragraph' },
 439+ 'f',
 440+ { 'type': '/paragraph' },
 441+ { 'type': '/listItem' }
 442+ ]
 443+ },
 444+ { 'type': 'retain', 'length': 2 },
 445+ {
 446+ 'type': 'remove',
 447+ 'data': [ 'g' ]
 448+ },
 449+ { 'type': 'retain', 'length': 9 }
 450+ ],
 451+ 'prepareRemoval strips and drops correctly when working across structural nodes (2)'
 452+ );
 453+
 454+ // Test 7
 455+ deepEqual(
 456+ documentModel.prepareRemoval( new es.Range( 9, 17 ) ).getOperations(),
 457+ [
 458+ { 'type': 'retain', 'length': 9 },
 459+ {
 460+ 'type': 'remove',
 461+ 'data': [ 'd' ]
 462+ },
 463+ { 'type': 'retain', 'length': 2 },
 464+ {
 465+ 'type': 'remove',
 466+ 'data': [
 467+ { 'type': 'listItem', 'attributes': { 'styles': ['bullet'] } },
 468+ { 'type': 'paragraph' },
 469+ 'e',
 470+ { 'type': '/paragraph' },
 471+ { 'type': '/listItem' }
 472+ ]
 473+ },
 474+ { 'type': 'retain', 'length': 17 }
 475+ ],
 476+ 'prepareRemoval will not merge items of unequal types'
 477+ );
 478+
 479+ // Test 8
 480+ deepEqual(
 481+ documentModel.prepareRemoval( new es.Range( 9, 27 ) ).getOperations(),
 482+ [
 483+ { 'type': 'retain', 'length': 9 },
 484+ {
 485+ 'type': 'remove',
 486+ 'data': [ 'd' ]
 487+ },
 488+ { 'type': 'retain', 'length': 2 },
 489+ {
 490+ 'type': 'remove',
 491+ 'data': [
 492+ { 'type': 'listItem', 'attributes': { 'styles': ['bullet'] } },
 493+ { 'type': 'paragraph' },
 494+ 'e',
 495+ { 'type': '/paragraph' },
 496+ { 'type': '/listItem' },
 497+ { 'type': 'listItem', 'attributes': { 'styles': ['bullet', 'bullet'] } },
 498+ { 'type': 'paragraph' },
 499+ 'f',
 500+ { 'type': '/paragraph' },
 501+ { 'type': '/listItem' },
 502+ { 'type': 'listItem', 'attributes': { 'styles': ['number'] } },
 503+ { 'type': 'paragraph' },
 504+ 'g',
 505+ { 'type': '/paragraph' },
 506+ { 'type': '/listItem' }
 507+ ]
 508+ },
 509+ { 'type': 'retain', 'length': 7 }
 510+ ],
 511+ 'prepareRemoval blanks a paragraph and a list'
 512+ );
413513 } );
414514
415515 test( 'es.DocumentModel.prepareInsertion', 11, function() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r103357Fix breakage in prepareRemoval() from r103271 and demonstrated by the tests i...catrope19:17, 16 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103271Rewrote prepareRemoval to support dropping nodes that are considered droppabl...tparscal00:03, 16 November 2011

Status & tagging log