Index: trunk/extensions/VisualEditor/tests/es/es.DocumentModel.test.js |
— | — | @@ -547,9 +547,13 @@ |
548 | 548 | ); |
549 | 549 | } ); |
550 | 550 | |
551 | | -test( 'es.DocumentModel.commit, es.DocumentModel.rollback', 12, function() { |
| 551 | +test( 'es.DocumentModel.commit, es.DocumentModel.rollback', /*18*/ 15, function() { |
552 | 552 | var documentModel = es.DocumentModel.newFromPlainObject( esTest.obj ); |
553 | 553 | |
| 554 | + // FIXME: These tests shouldn't use prepareFoo() because those functions |
| 555 | + // normalize the transactions they create and are tested separately. |
| 556 | + // We should be creating transactions directly and feeding those into |
| 557 | + // commit()/rollback() --Roan |
554 | 558 | var elementAttributeChange = documentModel.prepareElementAttributeChange( |
555 | 559 | 0, 'set', 'test', 1 |
556 | 560 | ); |
— | — | @@ -717,4 +721,73 @@ |
718 | 722 | ], |
719 | 723 | 'rollback keeps model tree up to date with removals' |
720 | 724 | ); |
| 725 | + |
| 726 | + var paragraphBreak = documentModel.prepareInsertion( 2, [ { 'type': '/paragraph' }, { 'type': 'paragraph' } ] ); |
| 727 | + |
| 728 | + // Test 13 |
| 729 | + documentModel.commit( paragraphBreak ); |
| 730 | + deepEqual( |
| 731 | + documentModel.getData( new es.Range( 0, 7 ) ), |
| 732 | + [ |
| 733 | + { 'type': 'paragraph' }, |
| 734 | + 'a', |
| 735 | + { 'type': '/paragraph' }, |
| 736 | + { 'type': 'paragraph' }, |
| 737 | + ['b', { 'type': 'textStyle/bold', 'hash': '#textStyle/bold' }], |
| 738 | + ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }], |
| 739 | + { 'type': '/paragraph' } |
| 740 | + ], |
| 741 | + 'commit applies an insertion transaction that splits the paragraph' |
| 742 | + ); |
| 743 | + |
| 744 | + // Test 14 |
| 745 | + deepEqual( |
| 746 | + documentModel.getChildren()[0].getContent(), |
| 747 | + ['a'], |
| 748 | + 'commit keeps model tree up to date with paragraph split (paragraph 1)' |
| 749 | + ); |
| 750 | + |
| 751 | + // Test 15 |
| 752 | + deepEqual( |
| 753 | + documentModel.getChildren()[1].getContent(), |
| 754 | + [ |
| 755 | + ['b', { 'type': 'textStyle/bold', 'hash': '#textStyle/bold' }], |
| 756 | + ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }] |
| 757 | + ], |
| 758 | + 'commit keeps model tree up to date with paragraph split (paragraph 2)' |
| 759 | + ); |
| 760 | + |
| 761 | + /* FIXME broken |
| 762 | + // Test 16 |
| 763 | + documentModel.rollback( paragraphBreak ); |
| 764 | + deepEqual( |
| 765 | + documentModel.getData( new es.Range( 0, 5 ) ), |
| 766 | + [ |
| 767 | + { 'type': 'paragraph' }, |
| 768 | + 'a', |
| 769 | + ['b', { 'type': 'textStyle/bold', 'hash': '#textStyle/bold' }], |
| 770 | + ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }], |
| 771 | + { 'type': '/paragraph' } |
| 772 | + ], |
| 773 | + 'rollback reverses the effect of a paragraph split on the content' |
| 774 | + ); |
| 775 | + |
| 776 | + // Test 17 |
| 777 | + deepEqual( |
| 778 | + documentModel.getChildren()[0].getContent(), |
| 779 | + [ |
| 780 | + 'a', |
| 781 | + ['b', { 'type': 'textStyle/bold', 'hash': '#textStyle/bold' }], |
| 782 | + ['c', { 'type': 'textStyle/italic', 'hash': '#textStyle/italic' }] |
| 783 | + ], |
| 784 | + 'rollback keeps model tree up to date with paragraph split (paragraphs are merged back)' |
| 785 | + ); |
| 786 | + |
| 787 | + // Test 18 |
| 788 | + deepEqual( |
| 789 | + documentModel.getChildren()[1].getElementType(), |
| 790 | + 'table', |
| 791 | + 'rollback keeps model tree up to date with paragraph split (table follows the paragraph)' |
| 792 | + ); |
| 793 | + */ |
721 | 794 | } ); |