Index: trunk/extensions/VisualEditor/tests/ve/ve.dm.TransactionProcessor.test.js |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | module( 've/dm' ); |
3 | 3 | |
4 | | -test( 've.dm.TransactionProcessor', 39, function() { |
| 4 | +test( 've.dm.TransactionProcessor', 47, function() { |
5 | 5 | var documentModel = ve.dm.DocumentNode.newFromPlainObject( veTest.obj ); |
6 | 6 | |
7 | 7 | // FIXME: These tests shouldn't use prepareFoo() because those functions |
— | — | @@ -366,6 +366,55 @@ |
367 | 367 | ); |
368 | 368 | |
369 | 369 | // 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 |
370 | 419 | ve.dm.TransactionProcessor.rollback( documentModel, listSplit ); |
371 | 420 | deepEqual( |
372 | 421 | documentModel.getData( new ve.Range( 15, 19 ) ), |
— | — | @@ -378,10 +427,45 @@ |
379 | 428 | 'rollback reverses list split' |
380 | 429 | ); |
381 | 430 | |
| 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 | + ); |
382 | 436 | |
| 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 | + |
383 | 467 | var contentReplacement = documentModel.prepareContentReplacement( new ve.Range( 32, 33 ), [ 'i', 'j', 'k' ] ); |
384 | 468 | |
385 | | - // Test 32 |
| 469 | + // Test 40 |
386 | 470 | ve.dm.TransactionProcessor.commit( documentModel, contentReplacement ); |
387 | 471 | deepEqual( |
388 | 472 | documentModel.getData( new ve.Range( 31, 36 ) ), |
— | — | @@ -393,7 +477,7 @@ |
394 | 478 | 'replacement replaces content' |
395 | 479 | ); |
396 | 480 | |
397 | | - // Test 33 |
| 481 | + // Test 41 |
398 | 482 | ve.dm.TransactionProcessor.rollback( documentModel, contentReplacement ); |
399 | 483 | deepEqual( |
400 | 484 | documentModel.getData( new ve.Range( 31, 34 ) ), |
— | — | @@ -407,7 +491,7 @@ |
408 | 492 | |
409 | 493 | var paragraphToHeading = documentModel.prepareWrap( new ve.Range( 1, 4 ), [ { 'type': 'paragraph' } ], [ { 'type': 'heading', 'level': 2 } ], [], [] ); |
410 | 494 | |
411 | | - // Test 34 |
| 495 | + // Test 42 |
412 | 496 | ve.dm.TransactionProcessor.commit( documentModel, paragraphToHeading ); |
413 | 497 | deepEqual( |
414 | 498 | documentModel.getData( new ve.Range( 0, 5 ) ), |
— | — | @@ -421,7 +505,7 @@ |
422 | 506 | 'changing paragraph to heading' |
423 | 507 | ); |
424 | 508 | |
425 | | - // Test 35 |
| 509 | + // Test 43 |
426 | 510 | ve.dm.TransactionProcessor.rollback( documentModel, paragraphToHeading ); |
427 | 511 | deepEqual( |
428 | 512 | documentModel.getData( new ve.Range( 0, 5 ) ), |
— | — | @@ -437,7 +521,7 @@ |
438 | 522 | |
439 | 523 | var unwrapList = documentModel.prepareWrap( new ve.Range( 12, 27 ), [ { 'type': 'list' } ], [] , [ { 'type': 'listItem' } ], [] ); |
440 | 524 | |
441 | | - // Test 36 |
| 525 | + // Test 44 |
442 | 526 | ve.dm.TransactionProcessor.commit( documentModel, unwrapList ); |
443 | 527 | deepEqual( |
444 | 528 | documentModel.getData( new ve.Range( 7, 21 ) ), |
— | — | @@ -460,7 +544,7 @@ |
461 | 545 | 'unwrapping the list produces a cell with four adjacent paragraphs' |
462 | 546 | ); |
463 | 547 | |
464 | | - // Test 37 |
| 548 | + // Test 45 |
465 | 549 | ve.dm.TransactionProcessor.rollback( documentModel, unwrapList ); |
466 | 550 | deepEqual( |
467 | 551 | documentModel.getData( new ve.Range( 7, 29 ) ), |
— | — | @@ -494,7 +578,7 @@ |
495 | 579 | var replaceTable = documentModel.prepareWrap( new ve.Range( 8, 28 ), [ { 'type': 'table' }, { 'type': 'tableRow' }, { 'type': 'tableCell' } ], |
496 | 580 | [ { 'type': 'list' }, { 'type': 'listItem' } ], [], [] ); |
497 | 581 | |
498 | | - // Test 38 |
| 582 | + // Test 46 |
499 | 583 | ve.dm.TransactionProcessor.commit( documentModel, replaceTable ); |
500 | 584 | deepEqual( |
501 | 585 | documentModel.getData( new ve.Range( 5, 30 ) ), |
— | — | @@ -528,7 +612,7 @@ |
529 | 613 | 'replacing a table with the list reverses the order of the closing tags correctly' |
530 | 614 | ); |
531 | 615 | |
532 | | - // Test 39 |
| 616 | + // Test 47 |
533 | 617 | ve.dm.TransactionProcessor.rollback( documentModel, replaceTable ); |
534 | 618 | deepEqual( |
535 | 619 | documentModel.getData( new ve.Range( 5, 32 ) ), |