Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Tests: Fixed tests after merging with master.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Sep 13, 2017
1 parent 2990734 commit 2c9f9a7
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions tests/undoengine-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'

import Range from '@ckeditor/ckeditor5-engine/src/model/range';
import Position from '@ckeditor/ckeditor5-engine/src/model/position';
import Element from '@ckeditor/ckeditor5-engine/src/model/element';
import UndoEngine from '../src/undoengine';

import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
Expand Down Expand Up @@ -211,43 +212,52 @@ describe( 'UndoEngine integration', () => {
} );

it( 'undo remove all content', () => {
input( '<p>foo[]</p>' );
input( '<paragraph>foo[]</paragraph>' );

doc.batch().remove( Range.createIn( root ) );
output( '[]' );
doc.enqueueChanges( () => {
doc.batch().remove( Range.createIn( root ) );
} );
output( '<paragraph>[]</paragraph>' ); // All hail our king and savior, autoparagraphing!

editor.execute( 'undo' );
output( '<p>foo[]</p>' );
output( '<paragraph>foo[]</paragraph>' );

undoDisabled();
} );

it( 'undo insert first content', () => {
input( '' );

doc.batch().insert( doc.selection.getFirstPosition(), new Element( 'p' ) );
output( '<p>[]</p>' );
doc.enqueueChanges( () => {
doc.batch().insert( doc.selection.getFirstPosition(), new Element( 'heading1' ) );
} );
output( '<heading1>[]</heading1>' );

editor.execute( 'undo' );
output( '[]' );
output( '<paragraph>[]</paragraph>' ); // All hail our king and savior, autoparagraphing!

undoDisabled();
} );

// #72.
it( 'undo paste multiple elements simulation', () => {
input( '<p></p>' );
input( '<paragraph></paragraph>' );

const p = root.getChild( 0 );
const pos = new Position( root, [ 0 ] );

doc.batch().remove( p ).insert( pos, new Element( 'p' ) ).insert( pos.getShiftedBy( 1 ), new Element( 'p' ) );
doc.enqueueChanges( () => {
doc.batch()
.remove( p )
.insert( pos, new Element( 'heading1' ) )
.insert( pos.getShiftedBy( 1 ), new Element( 'heading2' ) );
} );

output( '<p>[]</p><p></p>' );
output( '<heading1>[]</heading1><heading2></heading2>' );

editor.execute( 'undo' );

output( '<p>[]</p>' );
output( '<paragraph>[]</paragraph>' );

undoDisabled();
} );
Expand Down

0 comments on commit 2c9f9a7

Please sign in to comment.