Ver código fonte

Tests: Added a test to check if the DeleteCommand always passes the direction to the Model#deleteContent() method.

Aleksander Nowodzinski 5 anos atrás
pai
commit
7740b80d3b
1 arquivos alterados com 23 adições e 0 exclusões
  1. 23 0
      packages/ckeditor5-typing/tests/deletecommand.js

+ 23 - 0
packages/ckeditor5-typing/tests/deletecommand.js

@@ -184,6 +184,29 @@ describe( 'DeleteCommand', () => {
 			expect( deleteOpts ).to.have.property( 'doNotResetEntireContent', false );
 		} );
 
+		it( 'should pass the "direction" option to Model#deleteContent method', () => {
+			const spy = sinon.spy();
+			const forwardCommand = new DeleteCommand( editor, 'forward' );
+			editor.commands.add( 'forwardDelete', forwardCommand );
+
+			editor.model.on( 'deleteContent', spy );
+			setData( model, '<paragraph>foo[]bar</paragraph>' );
+
+			editor.execute( 'delete' );
+
+			expect( spy.callCount ).to.equal( 1 );
+
+			let deleteOpts = spy.args[ 0 ][ 1 ][ 1 ];
+			expect( deleteOpts ).to.have.property( 'direction', 'backward' );
+
+			editor.execute( 'forwardDelete' );
+
+			expect( spy.callCount ).to.equal( 2 );
+
+			deleteOpts = spy.args[ 1 ][ 1 ][ 1 ];
+			expect( deleteOpts ).to.have.property( 'direction', 'forward' );
+		} );
+
 		it( 'leaves an empty paragraph after removing the whole content from editor', () => {
 			setData( model, '<heading1>[Header 1</heading1><paragraph>Some text.]</paragraph>' );