From 4ed77d45bbfa94e895888f9325f3fdf43bbe227c Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Fri, 22 Feb 2019 09:02:44 +0200 Subject: [PATCH] [ACA-2221] Lock node - check selection is not null (#966) * check selection is not null * test --- src/app/directives/lock-node.directive.spec.ts | 6 ++++++ src/app/directives/lock-node.directive.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/directives/lock-node.directive.spec.ts b/src/app/directives/lock-node.directive.spec.ts index 0d497588b..ff444523e 100644 --- a/src/app/directives/lock-node.directive.spec.ts +++ b/src/app/directives/lock-node.directive.spec.ts @@ -69,6 +69,12 @@ describe('LockNodeDirective', () => { api = TestBed.get(AlfrescoApiService); }); + it('should return false if selection is null', () => { + component.selection = null; + fixture.detectChanges(); + expect(component.directive.isNodeLocked()).toBe(false); + }); + it('should return false if selection is not locked', () => { component.selection = { entry: { name: 'test-name', properties: {} } }; fixture.detectChanges(); diff --git a/src/app/directives/lock-node.directive.ts b/src/app/directives/lock-node.directive.ts index 3bb5e818d..6f328077b 100644 --- a/src/app/directives/lock-node.directive.ts +++ b/src/app/directives/lock-node.directive.ts @@ -54,7 +54,7 @@ export class LockNodeDirective { constructor(private alfrescoApiService: AlfrescoApiService) {} isNodeLocked(): boolean { - return isLocked(this.node); + return !!(this.node && isLocked(this.node)); } private async toggleLock(node: NodeEntry | SharedLinkEntry) {