[ADF-573] support for toggling enabled state (#1912)

This commit is contained in:
Denys Vuika
2017-05-30 14:28:12 +01:00
committed by Eugenio Romano
parent 4b5eb4bb29
commit 1ffc3cd080
6 changed files with 56 additions and 29 deletions

View File

@@ -15,6 +15,7 @@
* limitations under the License.
*/
import { ElementRef } from '@angular/core';
import { FileDraggableDirective } from '../directives/file-draggable.directive';
describe('FileDraggableDirective', () => {
@@ -22,7 +23,22 @@ describe('FileDraggableDirective', () => {
let component: FileDraggableDirective;
beforeEach( () => {
component = new FileDraggableDirective(null, null);
let el = new ElementRef(null);
component = new FileDraggableDirective(el, null);
});
it('should always be enabled by default', () => {
expect(component.enabled).toBeTruthy();
});
it('should not allow drad and drop when disabled', () => {
component.enabled = false;
let event = new CustomEvent('custom-event');
spyOn(event, 'preventDefault').and.stub();
component.onDropFiles(event);
component.onDragEnter(event);
component.onDragLeave(event);
expect(event.preventDefault).not.toHaveBeenCalled();
});
/*