This commit is contained in:
pionnegru 2019-11-14 08:16:40 +02:00
parent 88e6f98ed2
commit cdcc770e24

View File

@ -26,7 +26,10 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
import { InfoDrawerComponent } from './info-drawer.component'; import { InfoDrawerComponent } from './info-drawer.component';
import { TestBed, ComponentFixture, async } from '@angular/core/testing'; import { TestBed, ComponentFixture, async } from '@angular/core/testing';
import { Store } from '@ngrx/store'; 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 { AppTestingModule } from '../../testing/app-testing.module';
import { AppExtensionService } from '../../extensions/extension.service'; import { AppExtensionService } from '../../extensions/extension.service';
import { ContentApiService } from '@alfresco/aca-shared'; import { ContentApiService } from '@alfresco/aca-shared';
@ -159,4 +162,23 @@ describe('InfoDrawerComponent', () => {
expect(component.displayNode).toBe(response); expect(component.displayNode).toBe(response);
expect(contentApiService.getNodeInfo).toHaveBeenCalled(); expect(contentApiService.getNodeInfo).toHaveBeenCalled();
})); }));
it('should dispatch close panel on Esc keyboard event', () => {
const nodeMock = <any>{ 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()
);
});
}); });