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