Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix: UnlinkCommand should update its state upon editor load. Closes #93.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed May 12, 2017
1 parent 6d18c55 commit 6b015e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/unlinkcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export default class UnlinkCommand extends Command {

// Checks when command should be enabled or disabled.
this.listenTo( editor.document.selection, 'change:attribute', () => this.refreshState() );

// Determine the initial state of the command.
// https://github.com/ckeditor/ckeditor5-link/issues/93
this.refreshState();
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/unlinkcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ describe( 'UnlinkCommand', () => {

expect( refreshStateSpy.calledOnce ).to.true;
} );

// https://github.com/ckeditor/ckeditor5-link/issues/93
it( 'should determine the initial state of the command', () => {
const refreshStateSpy = testUtils.sinon.spy( UnlinkCommand.prototype, 'refreshState' );

new UnlinkCommand( editor );

expect( refreshStateSpy.calledOnce ).to.true;
} );
} );

describe( '_doExecute', () => {
Expand Down

0 comments on commit 6b015e2

Please sign in to comment.