|
@@ -184,48 +184,61 @@ describe( 'Command', () => {
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- describe( 'disable() / enable()', () => {
|
|
|
|
|
- it( 'disable() should disable the command', () => {
|
|
|
|
|
- command.disable( 'foo' );
|
|
|
|
|
|
|
+ describe( 'forceDisabled() / clearForceDisabled()', () => {
|
|
|
|
|
+ it( 'forceDisabled() should disable the command', () => {
|
|
|
|
|
+ command.forceDisabled( 'foo' );
|
|
|
command.isEnabled = true;
|
|
command.isEnabled = true;
|
|
|
|
|
|
|
|
expect( command.isEnabled ).to.be.false;
|
|
expect( command.isEnabled ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'enable() should enable the command', () => {
|
|
|
|
|
- command.disable( 'foo' );
|
|
|
|
|
- command.enable( 'foo' );
|
|
|
|
|
|
|
+ it( 'clearForceDisabled() should enable the command', () => {
|
|
|
|
|
+ command.forceDisabled( 'foo' );
|
|
|
|
|
+ command.clearForceDisabled( 'foo' );
|
|
|
|
|
|
|
|
expect( command.isEnabled ).to.be.true;
|
|
expect( command.isEnabled ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'enable() used with wrong identifier should not enable the command', () => {
|
|
|
|
|
- command.disable( 'foo' );
|
|
|
|
|
- command.enable( 'bar' );
|
|
|
|
|
|
|
+ it( 'clearForceDisabled() used with wrong identifier should not enable the command', () => {
|
|
|
|
|
+ command.forceDisabled( 'foo' );
|
|
|
|
|
+ command.clearForceDisabled( 'bar' );
|
|
|
command.isEnabled = true;
|
|
command.isEnabled = true;
|
|
|
|
|
|
|
|
expect( command.isEnabled ).to.be.false;
|
|
expect( command.isEnabled ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'using disable() twice with the same identifier should not have any effect', () => {
|
|
|
|
|
- command.disable( 'foo' );
|
|
|
|
|
- command.disable( 'foo' );
|
|
|
|
|
- command.enable( 'foo' );
|
|
|
|
|
|
|
+ it( 'using forceDisabled() twice with the same identifier should not have any effect', () => {
|
|
|
|
|
+ command.forceDisabled( 'foo' );
|
|
|
|
|
+ command.forceDisabled( 'foo' );
|
|
|
|
|
+ command.clearForceDisabled( 'foo' );
|
|
|
|
|
|
|
|
expect( command.isEnabled ).to.be.true;
|
|
expect( command.isEnabled ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'command is enabled only after whole disable stack is empty', () => {
|
|
|
|
|
- command.disable( 'foo' );
|
|
|
|
|
- command.disable( 'bar' );
|
|
|
|
|
- command.enable( 'foo' );
|
|
|
|
|
|
|
+ it( 'command is enabled only after all disables were cleared', () => {
|
|
|
|
|
+ command.forceDisabled( 'foo' );
|
|
|
|
|
+ command.forceDisabled( 'bar' );
|
|
|
|
|
+ command.clearForceDisabled( 'foo' );
|
|
|
command.isEnabled = true;
|
|
command.isEnabled = true;
|
|
|
|
|
|
|
|
expect( command.isEnabled ).to.be.false;
|
|
expect( command.isEnabled ).to.be.false;
|
|
|
|
|
|
|
|
- command.enable( 'bar' );
|
|
|
|
|
|
|
+ command.clearForceDisabled( 'bar' );
|
|
|
|
|
|
|
|
expect( command.isEnabled ).to.be.true;
|
|
expect( command.isEnabled ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'command should remain disabled if isEnabled has a callback disabling it', () => {
|
|
|
|
|
+ command.on( 'set:isEnabled', evt => {
|
|
|
|
|
+ evt.return = false;
|
|
|
|
|
+ evt.stop();
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ command.forceDisabled( 'foo' );
|
|
|
|
|
+ command.clearForceDisabled( 'foo' );
|
|
|
|
|
+ command.isEnabled = true;
|
|
|
|
|
+
|
|
|
|
|
+ expect( command.isEnabled ).to.be.false;
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|