[ADF-5377] Viewer: Image Crop (#6977)

* changed dependency

* Update lib/core/viewer/components/img-viewer.component.ts

Co-authored-by: Denys Vuika <denys.vuika@alfresco.com>

Co-authored-by: Denys Vuika <denys.vuika@alfresco.com>
This commit is contained in:
Urse Daniel
2021-05-06 17:21:15 +03:00
committed by GitHub
parent aa5cbea7f5
commit f5c29a5ec8
4 changed files with 48 additions and 1 deletions

View File

@@ -221,6 +221,26 @@ describe('Test Img viewer component ', () => {
expect(rotateButtonElement).toEqual(null);
});
it('should not show crop button by default', () => {
const rotateButtonElement = element.querySelector('#viewer-crop-button');
expect(rotateButtonElement).toEqual(null);
});
it('should start cropping when clicking the crop button', fakeAsync(() => {
component.readOnly = false;
spyOn(component, 'cropImage').and.callThrough();
spyOn(component.cropper, 'crop');
spyOn(component.cropper, 'setDragMode');
fixture.detectChanges();
const cropButtonElement = fixture.debugElement.query(By.css('#viewer-crop-button'));
cropButtonElement.triggerEventHandler('click', null);
tick();
expect(component.cropImage).toHaveBeenCalled();
expect(component.cropper.crop).toHaveBeenCalled();
expect(component.cropper.setDragMode).toHaveBeenCalledWith('crop');
}));
it('should rotate image by -90 degrees on button click', fakeAsync(() => {
component.readOnly = false;
spyOn(component, 'rotateImage').and.callThrough();
@@ -260,7 +280,7 @@ describe('Test Img viewer component ', () => {
expect(secondaryToolbar).toEqual(null);
});
it('should display second toolbar in rotate mode', fakeAsync(() => {
it('should display second toolbar in edit mode', fakeAsync(() => {
component.readOnly = false;
component.isEditing = true;
@@ -287,6 +307,13 @@ describe('Test Img viewer component ', () => {
expect(component.isEditing).toEqual(true);
});
it('should get in editing mode when the image gets cropped', () => {
component.readOnly = false;
component.cropImage();
expect(component.isEditing).toEqual(true);
});
it('should reset the scale and hide second toolbar', fakeAsync(() => {
component.readOnly = false;
component.isEditing = true;