Explorar o código

Tests: Improvements in core.Command tests.

Szymon Cofalik %!s(int64=9) %!d(string=hai) anos
pai
achega
a8a62309dc
Modificáronse 1 ficheiros con 12 adicións e 4 borrados
  1. 12 4
      packages/ckeditor5-engine/tests/command.js

+ 12 - 4
packages/ckeditor5-engine/tests/command.js

@@ -11,14 +11,14 @@ import Command from '/ckeditor5/core/command.js';
 let element, editor, command;
 
 class CommandWithSchema extends Command {
-	constructor( editor, schemaFails ) {
+	constructor( editor, schemaValid ) {
 		super( editor );
 
-		this.schemaFails = schemaFails;
+		this.schemaValid = schemaValid;
 	}
 
 	checkSchema() {
-		return this.schemaFails;
+		return this.schemaValid;
 	}
 }
 
@@ -52,7 +52,7 @@ describe( 'constructor', () => {
 
 		expect( command.checkSchema.called ).to.be.false;
 
-		let newCommand = new CommandWithSchema( editor, false );
+		let newCommand = new CommandWithSchema( editor, true );
 		sinon.spy( newCommand, 'checkSchema' );
 
 		newCommand.checkEnabled();
@@ -90,6 +90,14 @@ describe( 'checkEnabled', () => {
 
 		expect( command.isEnabled ).to.be.false;
 	} );
+
+	it( 'should set isEnabled to false if checkSchema returns false', () => {
+		let disabledCommand = new CommandWithSchema( editor, false );
+
+		disabledCommand.checkEnabled();
+
+		expect( disabledCommand.isEnabled ).to.be.false;
+	} );
 } );
 
 describe( 'disable', () => {