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

Tests: Secured HeadingCommand test with batch deltas count checks.

Aleksander Nowodzinski 8 лет назад
Родитель
Сommit
bfc96daad4
1 измененных файлов с 15 добавлено и 5 удалено
  1. 15 5
      packages/ckeditor5-heading/tests/headingcommand.js

+ 15 - 5
packages/ckeditor5-heading/tests/headingcommand.js

@@ -161,14 +161,13 @@ describe( 'HeadingCommand', () => {
 			it( 'does nothing when executed with already applied option', () => {
 			it( 'does nothing when executed with already applied option', () => {
 				const command = commands.heading1;
 				const command = commands.heading1;
 				const batch = document.batch();
 				const batch = document.batch();
-				const spy = sinon.spy( batch, 'rename' );
 
 
 				setData( document, '<heading1>foo[]bar</heading1>' );
 				setData( document, '<heading1>foo[]bar</heading1>' );
 
 
 				command.execute( { batch } );
 				command.execute( { batch } );
 
 
 				expect( getData( document ) ).to.equal( '<heading1>foo[]bar</heading1>' );
 				expect( getData( document ) ).to.equal( '<heading1>foo[]bar</heading1>' );
-				sinon.assert.notCalled( spy );
+				expect( batch.deltas ).to.be.empty;
 			} );
 			} );
 
 
 			it( 'converts topmost blocks', () => {
 			it( 'converts topmost blocks', () => {
@@ -209,12 +208,23 @@ describe( 'HeadingCommand', () => {
 				);
 				);
 			} );
 			} );
 
 
-			it( 'does nothing to the elements with same option', () => {
-				setData( document, '<heading1>foo[</heading1><heading1>bar</heading1><heading2>baz</heading2>]' );
+			it( 'does nothing to the elements with same option (#1)', () => {
+				setData( document, '<heading1>[foo</heading1><heading1>bar]</heading1>' );
+				const batch = document.batch();
+				commands.heading1.execute( { batch } );
+
+				expect( getData( document ) ).to.equal(
+					'<heading1>[foo</heading1><heading1>bar]</heading1>'
+				);
+				expect( batch.deltas ).to.be.empty;
+			} );
+
+			it( 'does nothing to the elements with same option (#2)', () => {
+				setData( document, '<heading1>[foo</heading1><heading1>bar</heading1><heading2>baz]</heading2>' );
 				commands.heading1.execute();
 				commands.heading1.execute();
 
 
 				expect( getData( document ) ).to.equal(
 				expect( getData( document ) ).to.equal(
-					'<heading1>foo[</heading1><heading1>bar</heading1><heading1>baz</heading1>]'
+					'<heading1>[foo</heading1><heading1>bar</heading1><heading1>baz]</heading1>'
 				);
 				);
 			} );
 			} );