浏览代码

Tests: Checked which event is used for disabling commands.

Oskar Wróbel 7 年之前
父节点
当前提交
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;
 		} );
+
+		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()', () => {