From cdcc770e241a2c49e068ad2aa93e13a77c6397d3 Mon Sep 17 00:00:00 2001 From: pionnegru Date: Thu, 14 Nov 2019 08:16:40 +0200 Subject: [PATCH] tests --- .../info-drawer/info-drawer.component.spec.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/components/info-drawer/info-drawer.component.spec.ts b/src/app/components/info-drawer/info-drawer.component.spec.ts index 57a442605..09ec936db 100644 --- a/src/app/components/info-drawer/info-drawer.component.spec.ts +++ b/src/app/components/info-drawer/info-drawer.component.spec.ts @@ -26,7 +26,10 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { InfoDrawerComponent } from './info-drawer.component'; import { TestBed, ComponentFixture, async } from '@angular/core/testing'; import { Store } from '@ngrx/store'; -import { SetInfoDrawerStateAction } from '@alfresco/aca-shared/store'; +import { + SetInfoDrawerStateAction, + ToggleInfoDrawerAction +} from '@alfresco/aca-shared/store'; import { AppTestingModule } from '../../testing/app-testing.module'; import { AppExtensionService } from '../../extensions/extension.service'; import { ContentApiService } from '@alfresco/aca-shared'; @@ -159,4 +162,23 @@ describe('InfoDrawerComponent', () => { expect(component.displayNode).toBe(response); expect(contentApiService.getNodeInfo).toHaveBeenCalled(); })); + + it('should dispatch close panel on Esc keyboard event', () => { + const nodeMock = { entry: { id: 'nodeId', aspectNames: [] } }; + component.node = nodeMock; + const event = new KeyboardEvent('keydown', { + code: 'Escape', + key: 'Escape', + keyCode: 27 + } as KeyboardEventInit); + + fixture.detectChanges(); + component.ngOnChanges(); + + fixture.debugElement.nativeElement.dispatchEvent(event); + + expect(storeMock.dispatch).toHaveBeenCalledWith( + new ToggleInfoDrawerAction() + ); + }); });