mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user