mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4387] Configuration option to change the dafault viewer zoom (#4645)
* [ADF-4387] Configuration option to change the dafault viewer zoom
This commit is contained in:
committed by
Eugenio Romano
parent
d52671823e
commit
a6552dbb17
@@ -28,6 +28,7 @@ import { CoreModule } from '../../core.module';
|
||||
import { TranslationService } from '../../services/translation.service';
|
||||
import { TranslationMock } from '../../mock/translation.service.mock';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { AppConfigService, AppConfigServiceMock } from '@alfresco/adf-core';
|
||||
|
||||
declare const pdfjsLib: any;
|
||||
|
||||
@@ -137,6 +138,7 @@ describe('Test PdfViewer component', () => {
|
||||
],
|
||||
providers: [
|
||||
{ provide: TranslationService, useClass: TranslationMock },
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||
{
|
||||
provide: MatDialog, useValue: {
|
||||
open: () => {
|
||||
@@ -634,4 +636,163 @@ describe('Test PdfViewer component', () => {
|
||||
|
||||
});
|
||||
|
||||
describe('Zoom customization', () => {
|
||||
|
||||
describe('default value', () => {
|
||||
|
||||
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
||||
let componentUrlTestComponent: UrlTestComponent;
|
||||
let elementUrlTestComponent: HTMLElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
fixtureUrlTestComponent = TestBed.createComponent(UrlTestComponent);
|
||||
componentUrlTestComponent = fixtureUrlTestComponent.componentInstance;
|
||||
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
||||
|
||||
fixtureUrlTestComponent.detectChanges();
|
||||
|
||||
componentUrlTestComponent.pdfViewerComponent.rendered
|
||||
.pipe(take(1))
|
||||
.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(elementUrlTestComponent);
|
||||
});
|
||||
|
||||
it('should use default zoom if is not present a custom zoom in the app.config', (done) => {
|
||||
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {
|
||||
});
|
||||
|
||||
fixtureUrlTestComponent.detectChanges();
|
||||
fixtureUrlTestComponent.whenStable().then(() => {
|
||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScale).toBe(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('custom value', () => {
|
||||
|
||||
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
||||
let componentUrlTestComponent: UrlTestComponent;
|
||||
let elementUrlTestComponent: HTMLElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config['adf-viewer.pdf-viewer-scaling'] = 80;
|
||||
|
||||
fixtureUrlTestComponent = TestBed.createComponent(UrlTestComponent);
|
||||
componentUrlTestComponent = fixtureUrlTestComponent.componentInstance;
|
||||
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
||||
|
||||
fixtureUrlTestComponent.detectChanges();
|
||||
|
||||
componentUrlTestComponent.pdfViewerComponent.rendered
|
||||
.pipe(take(1))
|
||||
.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(elementUrlTestComponent);
|
||||
});
|
||||
|
||||
it('should use the custom zoom if it is present in the app.config', (done) => {
|
||||
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {
|
||||
});
|
||||
|
||||
fixtureUrlTestComponent.detectChanges();
|
||||
fixtureUrlTestComponent.whenStable().then(() => {
|
||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScale).toBe(0.8);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('less than the minimum allowed value', () => {
|
||||
|
||||
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
||||
let componentUrlTestComponent: UrlTestComponent;
|
||||
let elementUrlTestComponent: HTMLElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config['adf-viewer.pdf-viewer-scaling'] = 10;
|
||||
|
||||
fixtureUrlTestComponent = TestBed.createComponent(UrlTestComponent);
|
||||
componentUrlTestComponent = fixtureUrlTestComponent.componentInstance;
|
||||
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
||||
|
||||
fixtureUrlTestComponent.detectChanges();
|
||||
|
||||
componentUrlTestComponent.pdfViewerComponent.rendered
|
||||
.pipe(take(1))
|
||||
.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(elementUrlTestComponent);
|
||||
});
|
||||
|
||||
it('should use the minimum scale zoom if the value given in app.config is less than the minimum allowed scale', (done) => {
|
||||
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {
|
||||
});
|
||||
|
||||
fixtureUrlTestComponent.detectChanges();
|
||||
|
||||
fixtureUrlTestComponent.whenStable().then(() => {
|
||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScale).toBe(0.25);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('greater than the maximum allowed value', () => {
|
||||
|
||||
let fixtureUrlTestComponent: ComponentFixture<UrlTestComponent>;
|
||||
let componentUrlTestComponent: UrlTestComponent;
|
||||
let elementUrlTestComponent: HTMLElement;
|
||||
|
||||
beforeEach((done) => {
|
||||
const appConfig: AppConfigService = TestBed.get(AppConfigService);
|
||||
appConfig.config['adf-viewer.pdf-viewer-scaling'] = 55555;
|
||||
|
||||
fixtureUrlTestComponent = TestBed.createComponent(UrlTestComponent);
|
||||
componentUrlTestComponent = fixtureUrlTestComponent.componentInstance;
|
||||
elementUrlTestComponent = fixtureUrlTestComponent.nativeElement;
|
||||
|
||||
fixtureUrlTestComponent.detectChanges();
|
||||
|
||||
componentUrlTestComponent.pdfViewerComponent.rendered
|
||||
.pipe(take(1))
|
||||
.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(elementUrlTestComponent);
|
||||
});
|
||||
|
||||
it('should use the maximum scale zoom if the value given in app.config is greater than the maximum allowed scale', (done) => {
|
||||
spyOn(componentUrlTestComponent.pdfViewerComponent.pdfViewer, 'forceRendering').and.callFake(() => {
|
||||
});
|
||||
|
||||
fixtureUrlTestComponent.detectChanges();
|
||||
fixtureUrlTestComponent.whenStable().then(() => {
|
||||
expect(componentUrlTestComponent.pdfViewerComponent.currentScale).toBe(10);
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user