mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Upgrade Viewer to angular 2.0.0-rc.1
This commit is contained in:
@@ -15,6 +15,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from '@angular/core/testing';
|
||||
|
||||
describe('Not Supported Format View', () => {
|
||||
it ('should be migrated to angular 2 rc.1', () => {
|
||||
expect(false).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
import { describe, expect, it, injectAsync, TestComponentBuilder } from 'angular2/testing';
|
||||
import { NotSupportedFormat } from './notSupportedFormat.component';
|
||||
|
||||
@@ -67,3 +77,4 @@ describe('Not Supported Format View', () => {
|
||||
}));
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input } from 'angular2/core';
|
||||
import { Component, Input } from '@angular/core';
|
||||
|
||||
declare let __moduleName: string;
|
||||
|
||||
|
@@ -15,163 +15,172 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { describe, expect, it, injectAsync, TestComponentBuilder, setBaseTestProviders } from 'angular2/testing';
|
||||
import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS } from 'angular2/platform/testing/browser';
|
||||
import { PdfViewerComponent } from './pdfViewer.component';
|
||||
import { PDFJSmock } from './assets/PDFJS.mock';
|
||||
import { PDFViewermock } from './assets/PDFViewer.mock';
|
||||
import { describe, it, expect } from '@angular/core/testing';
|
||||
|
||||
describe('PdfViewer', () => {
|
||||
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
|
||||
describe('View', () => {
|
||||
it('Canvas should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(PdfViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-viewerPdf')).not.toBeNull();
|
||||
expect(element.querySelector('#viewer-pdf-container')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('Loader should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(PdfViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-loader')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
it('Next an Previous Buttons should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(PdfViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||
expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('Input Page elements should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(PdfViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-pagenumber-input')).toBeDefined();
|
||||
expect(element.querySelector('#viewer-total-pages')).toBeDefined();
|
||||
|
||||
expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||
expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('User interaction', () => {
|
||||
it('Total number of pages should be loaded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(PdfViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
component.urlFile = 'fake-url-file';
|
||||
spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
spyOn(component, 'initPDFViewer').and.callFake(() => {
|
||||
component.pdfViewer = new PDFViewermock();
|
||||
});
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
expect(component.totalPages).toEqual('10');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('nextPage should move to the next page', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(PdfViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
spyOn(component, 'initPDFViewer').and.callFake(() => {
|
||||
component.pdfViewer = new PDFViewermock();
|
||||
});
|
||||
|
||||
component.urlFile = 'fake-url-file';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.displayPage).toBe(1);
|
||||
component.nextPage();
|
||||
fixture.detectChanges();
|
||||
expect(component.displayPage).toBe(2);
|
||||
}).catch((error) => {
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('previous page should move to the previous page', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(PdfViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
spyOn(component, 'initPDFViewer').and.callFake(() => {
|
||||
component.pdfViewer = new PDFViewermock();
|
||||
});
|
||||
|
||||
component.urlFile = 'fake-url-file';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.displayPage).toBe(1);
|
||||
component.nextPage();
|
||||
component.nextPage();
|
||||
component.previousPage();
|
||||
fixture.detectChanges();
|
||||
expect(component.displayPage).toBe(2);
|
||||
}).catch((error) => {
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
it('previous page should not move to the previous page if is page 1', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(PdfViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
spyOn(component, 'initPDFViewer').and.callFake(() => {
|
||||
component.pdfViewer = new PDFViewermock();
|
||||
});
|
||||
|
||||
component.urlFile = 'fake-url-file';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.displayPage).toBe(1);
|
||||
component.previousPage();
|
||||
fixture.detectChanges();
|
||||
expect(component.displayPage).toBe(1);
|
||||
}).catch((error) => {
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
});
|
||||
}));
|
||||
it ('should be migrated to angular 2 rc.1', () => {
|
||||
expect(false).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
// import { describe, expect, it, injectAsync, TestComponentBuilder, setBaseTestProviders } from 'angular2/testing';
|
||||
// import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS } from 'angular2/platform/testing/browser';
|
||||
// import { PdfViewerComponent } from './pdfViewer.component';
|
||||
// import { PDFJSmock } from './assets/PDFJS.mock';
|
||||
// import { PDFViewermock } from './assets/PDFViewer.mock';
|
||||
//
|
||||
// describe('PdfViewer', () => {
|
||||
// setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
//
|
||||
// describe('View', () => {
|
||||
// it('Canvas should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(PdfViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let element = fixture.nativeElement;
|
||||
//
|
||||
// fixture.detectChanges();
|
||||
//
|
||||
// expect(element.querySelector('#viewer-viewerPdf')).not.toBeNull();
|
||||
// expect(element.querySelector('#viewer-pdf-container')).not.toBeNull();
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('Loader should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(PdfViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let element = fixture.nativeElement;
|
||||
//
|
||||
// fixture.detectChanges();
|
||||
//
|
||||
// expect(element.querySelector('#viewer-loader')).not.toBeNull();
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
//
|
||||
// it('Next an Previous Buttons should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(PdfViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let element = fixture.nativeElement;
|
||||
//
|
||||
// fixture.detectChanges();
|
||||
//
|
||||
// expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||
// expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('Input Page elements should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(PdfViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let element = fixture.nativeElement;
|
||||
//
|
||||
// fixture.detectChanges();
|
||||
//
|
||||
// expect(element.querySelector('#viewer-pagenumber-input')).toBeDefined();
|
||||
// expect(element.querySelector('#viewer-total-pages')).toBeDefined();
|
||||
//
|
||||
// expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||
// expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||
// });
|
||||
// }));
|
||||
// });
|
||||
//
|
||||
// describe('User interaction', () => {
|
||||
// it('Total number of pages should be loaded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(PdfViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// component.urlFile = 'fake-url-file';
|
||||
// spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
// spyOn(component, 'initPDFViewer').and.callFake(() => {
|
||||
// component.pdfViewer = new PDFViewermock();
|
||||
// });
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// expect(component.totalPages).toEqual('10');
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('nextPage should move to the next page', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(PdfViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
// spyOn(component, 'initPDFViewer').and.callFake(() => {
|
||||
// component.pdfViewer = new PDFViewermock();
|
||||
// });
|
||||
//
|
||||
// component.urlFile = 'fake-url-file';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(component.displayPage).toBe(1);
|
||||
// component.nextPage();
|
||||
// fixture.detectChanges();
|
||||
// expect(component.displayPage).toBe(2);
|
||||
// }).catch((error) => {
|
||||
// expect(error).toBeUndefined();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('previous page should move to the previous page', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(PdfViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
// spyOn(component, 'initPDFViewer').and.callFake(() => {
|
||||
// component.pdfViewer = new PDFViewermock();
|
||||
// });
|
||||
//
|
||||
// component.urlFile = 'fake-url-file';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(component.displayPage).toBe(1);
|
||||
// component.nextPage();
|
||||
// component.nextPage();
|
||||
// component.previousPage();
|
||||
// fixture.detectChanges();
|
||||
// expect(component.displayPage).toBe(2);
|
||||
// }).catch((error) => {
|
||||
// expect(error).toBeUndefined();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// /* tslint:disable:max-line-length */
|
||||
// it('previous page should not move to the previous page if is page 1', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(PdfViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
// spyOn(component, 'initPDFViewer').and.callFake(() => {
|
||||
// component.pdfViewer = new PDFViewermock();
|
||||
// });
|
||||
//
|
||||
// component.urlFile = 'fake-url-file';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(component.displayPage).toBe(1);
|
||||
// component.previousPage();
|
||||
// fixture.detectChanges();
|
||||
// expect(component.displayPage).toBe(1);
|
||||
// }).catch((error) => {
|
||||
// expect(error).toBeUndefined();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
// });
|
||||
// });
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, HostListener } from 'angular2/core';
|
||||
import { Component, Input, HostListener } from '@angular/core';
|
||||
|
||||
declare let PDFJS: any;
|
||||
declare let __moduleName: string;
|
||||
|
@@ -15,242 +15,251 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { describe, expect, it, injectAsync, TestComponentBuilder } from 'angular2/testing';
|
||||
import { ViewerComponent } from './viewer.component';
|
||||
import { describe, it, expect } from '@angular/core/testing';
|
||||
|
||||
describe('ViewerComponent', () => {
|
||||
|
||||
describe('View', () => {
|
||||
it('shadow overlay should be present if overlay is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
let component = fixture.componentInstance;
|
||||
component.urlFile = 'fake-url-file';
|
||||
component.overlayMode = true;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-shadow-transparent')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('Name File should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
let component = fixture.componentInstance;
|
||||
component.urlFile = 'http://localhost:9876/fake-url-file.pdf';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('fake-url-file.pdf');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
it('should pick up filename from the fileName property when specified', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
let component = fixture.componentInstance;
|
||||
component.urlFile = 'http://localhost:9876/fake-url-file.pdf';
|
||||
component.fileName = 'My Example.pdf';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('My Example.pdf');
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('Close button should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
let component = fixture.componentInstance;
|
||||
component.urlFile = 'fake-url-file';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-close-button')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('Click on close button should hide the viewer', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
let component = fixture.componentInstance;
|
||||
component.urlFile = 'fake-url-file';
|
||||
|
||||
fixture.detectChanges();
|
||||
element.querySelector('#viewer-close-button').click();
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-main-container')).toBeNull();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('Attribute', () => {
|
||||
it('Url File should be mandatory', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
component.showViewer = true;
|
||||
|
||||
expect(() => {
|
||||
component.ngOnChanges();
|
||||
}).toThrow();
|
||||
});
|
||||
}));
|
||||
|
||||
it('showViewer default value should be true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
|
||||
expect(component.showViewer).toBe(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('if showViewer value is false the viewer should be hide', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
let element = fixture.nativeElement;
|
||||
component.urlFile = 'fake-url-file';
|
||||
component.showViewer = false;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-main-container')).toBeNull();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
describe('Extension Type Test', () => {
|
||||
it('if extension file is a pdf the pdf viewer should be loaded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
let element = fixture.nativeElement;
|
||||
component.urlFile = 'fake-url-file.pdf';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('pdf-viewer')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
it('if extension file is a image the img viewer should be loaded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
let element = fixture.nativeElement;
|
||||
component.urlFile = 'fake-url-file.png';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-image')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
it('if extension file is a not supported the not supported div should be loaded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
let element = fixture.nativeElement;
|
||||
component.urlFile = 'fake-url-file.unsupported';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('not-supported-format')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
describe('MimeType handling', () => {
|
||||
it('should display a PDF file identified by mimetype when the filename has no extension', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
let element = fixture.nativeElement;
|
||||
component.urlFile = 'content';
|
||||
component.mimeType = 'application/pdf';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('pdf-viewer')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display a PDF file identified by mimetype when the file extension is wrong', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
let element = fixture.nativeElement;
|
||||
component.urlFile = 'content.bin';
|
||||
component.mimeType = 'application/pdf';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('pdf-viewer')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display an image file identified by mimetype when the filename has no extension', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
let element = fixture.nativeElement;
|
||||
component.urlFile = 'content';
|
||||
component.mimeType = 'image/png';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-image')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should display a image file identified by mimetype when the file extension is wrong', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
let element = fixture.nativeElement;
|
||||
component.urlFile = 'content.bin';
|
||||
component.mimeType = 'image/png';
|
||||
|
||||
component.ngOnChanges().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-image')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
}));
|
||||
it ('should be migrated to angular 2 rc.1', () => {
|
||||
expect(false).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
/* tslint:disable:max-line-length */
|
||||
// import { describe, expect, it, injectAsync, TestComponentBuilder } from 'angular2/testing';
|
||||
// import { ViewerComponent } from './viewer.component';
|
||||
//
|
||||
// describe('ViewerComponent', () => {
|
||||
//
|
||||
// describe('View', () => {
|
||||
// it('shadow overlay should be present if overlay is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let element = fixture.nativeElement;
|
||||
// let component = fixture.componentInstance;
|
||||
// component.urlFile = 'fake-url-file';
|
||||
// component.overlayMode = true;
|
||||
//
|
||||
// fixture.detectChanges();
|
||||
//
|
||||
// expect(element.querySelector('#viewer-shadow-transparent')).not.toBeNull();
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('Name File should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let element = fixture.nativeElement;
|
||||
// let component = fixture.componentInstance;
|
||||
// component.urlFile = 'http://localhost:9876/fake-url-file.pdf';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('fake-url-file.pdf');
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// /* tslint:disable:max-line-length */
|
||||
// it('should pick up filename from the fileName property when specified', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let element = fixture.nativeElement;
|
||||
// let component = fixture.componentInstance;
|
||||
// component.urlFile = 'http://localhost:9876/fake-url-file.pdf';
|
||||
// component.fileName = 'My Example.pdf';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('My Example.pdf');
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('Close button should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let element = fixture.nativeElement;
|
||||
// let component = fixture.componentInstance;
|
||||
// component.urlFile = 'fake-url-file';
|
||||
//
|
||||
// fixture.detectChanges();
|
||||
//
|
||||
// expect(element.querySelector('#viewer-close-button')).not.toBeNull();
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('Click on close button should hide the viewer', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let element = fixture.nativeElement;
|
||||
// let component = fixture.componentInstance;
|
||||
// component.urlFile = 'fake-url-file';
|
||||
//
|
||||
// fixture.detectChanges();
|
||||
// element.querySelector('#viewer-close-button').click();
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('#viewer-main-container')).toBeNull();
|
||||
// });
|
||||
// }));
|
||||
// });
|
||||
//
|
||||
// describe('Attribute', () => {
|
||||
// it('Url File should be mandatory', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// component.showViewer = true;
|
||||
//
|
||||
// expect(() => {
|
||||
// component.ngOnChanges();
|
||||
// }).toThrow();
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('showViewer default value should be true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
//
|
||||
// expect(component.showViewer).toBe(true);
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('if showViewer value is false the viewer should be hide', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// let element = fixture.nativeElement;
|
||||
// component.urlFile = 'fake-url-file';
|
||||
// component.showViewer = false;
|
||||
//
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('#viewer-main-container')).toBeNull();
|
||||
// });
|
||||
// }));
|
||||
// });
|
||||
//
|
||||
// /* tslint:disable:max-line-length */
|
||||
// describe('Extension Type Test', () => {
|
||||
// it('if extension file is a pdf the pdf viewer should be loaded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// let element = fixture.nativeElement;
|
||||
// component.urlFile = 'fake-url-file.pdf';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('pdf-viewer')).not.toBeNull();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// /* tslint:disable:max-line-length */
|
||||
// it('if extension file is a image the img viewer should be loaded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// let element = fixture.nativeElement;
|
||||
// component.urlFile = 'fake-url-file.png';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('#viewer-image')).not.toBeNull();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// /* tslint:disable:max-line-length */
|
||||
// it('if extension file is a not supported the not supported div should be loaded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// let element = fixture.nativeElement;
|
||||
// component.urlFile = 'fake-url-file.unsupported';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('not-supported-format')).not.toBeNull();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
// });
|
||||
//
|
||||
// /* tslint:disable:max-line-length */
|
||||
// describe('MimeType handling', () => {
|
||||
// it('should display a PDF file identified by mimetype when the filename has no extension', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// let element = fixture.nativeElement;
|
||||
// component.urlFile = 'content';
|
||||
// component.mimeType = 'application/pdf';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('pdf-viewer')).not.toBeNull();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('should display a PDF file identified by mimetype when the file extension is wrong', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// let element = fixture.nativeElement;
|
||||
// component.urlFile = 'content.bin';
|
||||
// component.mimeType = 'application/pdf';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('pdf-viewer')).not.toBeNull();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('should display an image file identified by mimetype when the filename has no extension', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// let element = fixture.nativeElement;
|
||||
// component.urlFile = 'content';
|
||||
// component.mimeType = 'image/png';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('#viewer-image')).not.toBeNull();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
//
|
||||
// it('should display a image file identified by mimetype when the file extension is wrong', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
// return tcb
|
||||
// .createAsync(ViewerComponent)
|
||||
// .then((fixture) => {
|
||||
// let component = fixture.componentInstance;
|
||||
// let element = fixture.nativeElement;
|
||||
// component.urlFile = 'content.bin';
|
||||
// component.mimeType = 'image/png';
|
||||
//
|
||||
// component.ngOnChanges().then(() => {
|
||||
// fixture.detectChanges();
|
||||
// expect(element.querySelector('#viewer-image')).not.toBeNull();
|
||||
// });
|
||||
// });
|
||||
// }));
|
||||
// });
|
||||
// });
|
||||
|
@@ -15,8 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ElementRef, Input, Output, HostListener } from 'angular2/core';
|
||||
import { EventEmitter } from 'angular2/src/facade/async';
|
||||
import { Component, ElementRef, Input, Output, HostListener, EventEmitter } from '@angular/core';
|
||||
import { PdfViewerComponent } from './pdfViewer.component';
|
||||
import { NotSupportedFormat } from './notSupportedFormat.component';
|
||||
|
||||
|
Reference in New Issue
Block a user