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

Tests: Checked which event is used for disabling commands.

Oskar Wróbel 7 лет назад
Родитель
Сommit
adc4bb180e
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      packages/ckeditor5-core/tests/command.js

+ 16 - 0
packages/ckeditor5-core/tests/command.js

@@ -98,6 +98,22 @@ describe( 'Command', () => {
 
 
 			expect( editor.something ).to.false;
 			expect( editor.something ).to.false;
 		} );
 		} );
+
+		it( 'stops beforeChange event to force disabled and not affect change event', () => {
+			const beforeChangeSpy = sinon.spy();
+			const changeSpy = sinon.spy();
+
+			command.isEnabled = true;
+			editor.isReadOnly = false;
+
+			command.on( 'beforeChange', beforeChangeSpy );
+			command.on( 'change', changeSpy );
+
+			editor.isReadOnly = true;
+
+			sinon.assert.notCalled( beforeChangeSpy );
+			sinon.assert.calledOnce( changeSpy );
+		} );
 	} );
 	} );
 
 
 	describe( 'execute()', () => {
 	describe( 'execute()', () => {