8
0
Просмотр исходного кода

Add tests for transparent undo batches.

Maciej Gołaszewski 6 лет назад
Родитель
Сommit
56161861db
1 измененных файлов с 31 добавлено и 0 удалено
  1. 31 0
      packages/ckeditor5-undo/tests/undoediting.js

+ 31 - 0
packages/ckeditor5-undo/tests/undoediting.js

@@ -82,6 +82,27 @@ describe( 'UndoEditing', () => {
 		expect( undo._redoCommand.clearStack.called ).to.be.false;
 	} );
 
+	it( 'should add redo batch to undo', () => {
+		sinon.spy( undo._undoCommand, 'addBatch' );
+
+		model.change( writer => {
+			writer.insertText( 'foobar', root );
+		} );
+
+		model.change( writer => {
+			writer.insertText( 'baz', root );
+		} );
+
+		editor.execute( 'undo' );
+		editor.execute( 'undo' );
+
+		editor.execute( 'redo' );
+		sinon.assert.calledThrice( undo._undoCommand.addBatch );
+
+		editor.execute( 'redo' );
+		sinon.assert.callCount( undo._undoCommand.addBatch, 4 );
+	} );
+
 	it( 'should not add a batch that has only non-document operations', () => {
 		sinon.spy( undo._undoCommand, 'addBatch' );
 
@@ -95,6 +116,16 @@ describe( 'UndoEditing', () => {
 		expect( undo._undoCommand.addBatch.called ).to.be.false;
 	} );
 
+	it( 'should not add a transparent batch', () => {
+		sinon.spy( undo._undoCommand, 'addBatch' );
+
+		model.enqueueChange( 'transparent', writer => {
+			writer.insertText( 'foobar', root );
+		} );
+
+		expect( undo._undoCommand.addBatch.called ).to.be.false;
+	} );
+
 	it( 'should add a batch that has both document and non-document operations', () => {
 		sinon.spy( undo._undoCommand, 'addBatch' );