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 15, 2017
1 parent 6d18c55 commit 80aad4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/unlinkcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export default class UnlinkCommand extends Command {
super( editor );

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

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/unlinkcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ describe( 'UnlinkCommand', () => {
} );

describe( 'constructor()', () => {
it( 'should listen on selection attribute change and refresh state', () => {
it( 'should listen on document#changesDone and refresh the state', () => {
const refreshStateSpy = testUtils.sinon.spy( command, 'refreshState' );

document.selection.fire( 'change:attribute' );
document.fire( 'changesDone' );

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

0 comments on commit 80aad4e

Please sign in to comment.