|
|
@@ -32,7 +32,7 @@ describe( 'UndoEngine', () => {
|
|
|
expect( editor.commands.get( 'redo' ) ).to.equal( undo._redoCommand );
|
|
|
} );
|
|
|
|
|
|
- it( 'should add a batch to undo command and clear redo stack, if it\'s type is different than "undo" and "redo"', () => {
|
|
|
+ it( 'should add a batch to undo command and clear redo stack, if it\'s type is "default"', () => {
|
|
|
sinon.spy( undo._undoCommand, 'addBatch' );
|
|
|
sinon.spy( undo._redoCommand, 'clearStack' );
|
|
|
|
|
|
@@ -45,29 +45,35 @@ describe( 'UndoEngine', () => {
|
|
|
expect( undo._redoCommand.clearStack.calledOnce ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
- it( 'should add a batch to undo command, if it\'s type is redo and not clear redo stack', () => {
|
|
|
+ it( 'should add each batch only once', () => {
|
|
|
sinon.spy( undo._undoCommand, 'addBatch' );
|
|
|
- sinon.spy( undo._redoCommand, 'clearStack' );
|
|
|
|
|
|
- batch.type = 'redo';
|
|
|
+ batch.insert( new Position( root, [ 0 ] ), 'foobar' ).insert( new Position( root, [ 0 ] ), 'foobar' );
|
|
|
|
|
|
- expect( undo._undoCommand.addBatch.called ).to.be.false;
|
|
|
- expect( undo._redoCommand.clearStack.called ).to.be.false;
|
|
|
+ expect( undo._undoCommand.addBatch.calledOnce ).to.be.true;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should add a batch to undo command, if it\'s type is undo and it comes from redo command', () => {
|
|
|
+ sinon.spy( undo._undoCommand, 'addBatch' );
|
|
|
+ sinon.spy( undo._redoCommand, 'clearStack' );
|
|
|
+
|
|
|
+ undo._redoCommand._createdBatches.add( batch );
|
|
|
|
|
|
batch.insert( new Position( root, [ 0 ] ), 'foobar' );
|
|
|
|
|
|
expect( undo._undoCommand.addBatch.calledOnce ).to.be.true;
|
|
|
- expect( undo._redoCommand.clearStack.calledOnce ).to.be.false;
|
|
|
+ expect( undo._redoCommand.clearStack.called ).to.be.false;
|
|
|
} );
|
|
|
|
|
|
it( 'should add a batch to redo command, if it\'s type is undo', () => {
|
|
|
- batch.type = 'undo';
|
|
|
-
|
|
|
sinon.spy( undo._redoCommand, 'addBatch' );
|
|
|
+ sinon.spy( undo._redoCommand, 'clearStack' );
|
|
|
+
|
|
|
+ undo._undoCommand._createdBatches.add( batch );
|
|
|
|
|
|
batch.insert( new Position( root, [ 0 ] ), 'foobar' );
|
|
|
|
|
|
expect( undo._redoCommand.addBatch.calledOnce ).to.be.true;
|
|
|
- expect( undo._redoCommand.addBatch.calledWith( batch ) ).to.be.true;
|
|
|
+ expect( undo._redoCommand.clearStack.called ).to.be.false;
|
|
|
} );
|
|
|
} );
|