fix test viewer RC1

This commit is contained in:
Eugenio Romano
2016-06-14 18:39:13 +01:00
parent 67d99e2c31
commit bf2791bacb
3 changed files with 405 additions and 426 deletions

View File

@@ -15,23 +15,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { describe, it, expect } from '@angular/core/testing'; import { describe, expect, it, inject } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/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'; import { NotSupportedFormat } from './notSupportedFormat.component';
describe('Not Supported Format View', () => { describe('Not Supported Format View', () => {
describe('View', () => { describe('View', () => {
it('Download button should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { it('Download button should be present', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb return tcb
.createAsync(NotSupportedFormat) .createAsync(NotSupportedFormat)
.then((fixture) => { .then((fixture) => {
@@ -42,7 +33,7 @@ describe('Not Supported Format View', () => {
expect(element.querySelector('#viewer-download-button')).not.toBeNull(); expect(element.querySelector('#viewer-download-button')).not.toBeNull();
}); });
})); }));
it('should display the name of the file', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { it('should display the name of the file', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb return tcb
.createAsync(NotSupportedFormat) .createAsync(NotSupportedFormat)
.then((fixture) => { .then((fixture) => {
@@ -58,7 +49,7 @@ describe('Not Supported Format View', () => {
}); });
describe('User Interaction', () => { describe('User Interaction', () => {
it('Click on Download button should call download method', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { it('Click on Download button should call download method', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb return tcb
.createAsync(NotSupportedFormat) .createAsync(NotSupportedFormat)
.then((fixture) => { .then((fixture) => {
@@ -77,4 +68,4 @@ describe('Not Supported Format View', () => {
})); }));
}); });
}); });
*/

View File

@@ -15,172 +15,168 @@
* limitations under the License. * limitations under the License.
*/ */
import { describe, it, expect } from '@angular/core/testing'; import { describe, expect, it, inject, setBaseTestProviders } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import {
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
} from '@angular/platform-browser-dynamic/testing';
import { PdfViewerComponent } from './pdfViewer.component';
import { PDFJSmock } from './assets/PDFJS.mock';
import { PDFViewermock } from './assets/PDFViewer.mock';
describe('PdfViewer', () => { describe('PdfViewer', () => {
it ('should be migrated to angular 2 rc.1', () => { setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
expect(false).toBe(true); TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
describe('View', () => {
it('Canvas should be present', inject([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', inject([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', inject([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', inject([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', inject([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', inject([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', inject([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 */ /* tslint:disable:max-line-length */
// import { describe, expect, it, injectAsync, TestComponentBuilder, setBaseTestProviders } from 'angular2/testing'; it('previous page should not move to the previous page if is page 1', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
// import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS } from 'angular2/platform/testing/browser'; return tcb
// import { PdfViewerComponent } from './pdfViewer.component'; .createAsync(PdfViewerComponent)
// import { PDFJSmock } from './assets/PDFJS.mock'; .then((fixture) => {
// import { PDFViewermock } from './assets/PDFViewer.mock'; let component = fixture.componentInstance;
// spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
// describe('PdfViewer', () => { spyOn(component, 'initPDFViewer').and.callFake(() => {
// setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS); component.pdfViewer = new PDFViewermock();
// });
// describe('View', () => {
// it('Canvas should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { component.urlFile = 'fake-url-file';
// return tcb
// .createAsync(PdfViewerComponent) component.ngOnChanges().then(() => {
// .then((fixture) => { fixture.detectChanges();
// let element = fixture.nativeElement; expect(component.displayPage).toBe(1);
// component.previousPage();
// fixture.detectChanges(); fixture.detectChanges();
// expect(component.displayPage).toBe(1);
// expect(element.querySelector('#viewer-viewerPdf')).not.toBeNull(); }).catch((error) => {
// expect(element.querySelector('#viewer-pdf-container')).not.toBeNull(); expect(error).toBeUndefined();
// }); });
// })); });
// }));
// 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();
// });
// });
// }));
// });
// });

View File

@@ -15,251 +15,243 @@
* limitations under the License. * limitations under the License.
*/ */
import { describe, it, expect } from '@angular/core/testing'; import {describe, expect, it, inject } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import { ViewerComponent } from './viewer.component';
describe('ViewerComponent', () => { describe('ViewerComponent', () => {
it ('should be migrated to angular 2 rc.1', () => {
expect(false).toBe(true); describe('View', () => {
it('shadow overlay should be present if overlay is true', inject([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', inject([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', inject([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', inject([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', inject([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', inject([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', inject([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', inject([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 */ /* tslint:disable:max-line-length */
// import { describe, expect, it, injectAsync, TestComponentBuilder } from 'angular2/testing'; describe('Extension Type Test', () => {
// import { ViewerComponent } from './viewer.component'; it('if extension file is a pdf the pdf viewer should be loaded', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
// return tcb
// describe('ViewerComponent', () => { .createAsync(ViewerComponent)
// .then((fixture) => {
// describe('View', () => { let component = fixture.componentInstance;
// it('shadow overlay should be present if overlay is true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { let element = fixture.nativeElement;
// return tcb component.urlFile = 'fake-url-file.pdf';
// .createAsync(ViewerComponent)
// .then((fixture) => { component.ngOnChanges().then(() => {
// let element = fixture.nativeElement; fixture.detectChanges();
// let component = fixture.componentInstance; expect(element.querySelector('pdf-viewer')).not.toBeNull();
// component.urlFile = 'fake-url-file'; });
// component.overlayMode = true; });
// }));
// fixture.detectChanges();
// /* tslint:disable:max-line-length */
// expect(element.querySelector('#viewer-shadow-transparent')).not.toBeNull(); it('if extension file is a image the img viewer should be loaded', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
// }); return tcb
// })); .createAsync(ViewerComponent)
// .then((fixture) => {
// it('Name File should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { let component = fixture.componentInstance;
// return tcb let element = fixture.nativeElement;
// .createAsync(ViewerComponent) component.urlFile = 'fake-url-file.png';
// .then((fixture) => {
// let element = fixture.nativeElement; component.ngOnChanges().then(() => {
// let component = fixture.componentInstance; fixture.detectChanges();
// component.urlFile = 'http://localhost:9876/fake-url-file.pdf'; expect(element.querySelector('#viewer-image')).not.toBeNull();
// });
// component.ngOnChanges().then(() => { });
// fixture.detectChanges(); }));
// expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('fake-url-file.pdf');
// }); /* tslint:disable:max-line-length */
// }); it('if extension file is a not supported the not supported div should be loaded', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
// })); return tcb
// .createAsync(ViewerComponent)
// /* tslint:disable:max-line-length */ .then((fixture) => {
// it('should pick up filename from the fileName property when specified', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { let component = fixture.componentInstance;
// return tcb let element = fixture.nativeElement;
// .createAsync(ViewerComponent) component.urlFile = 'fake-url-file.unsupported';
// .then((fixture) => {
// let element = fixture.nativeElement; component.ngOnChanges().then(() => {
// let component = fixture.componentInstance; fixture.detectChanges();
// component.urlFile = 'http://localhost:9876/fake-url-file.pdf'; expect(element.querySelector('not-supported-format')).not.toBeNull();
// component.fileName = 'My Example.pdf'; });
// });
// component.ngOnChanges().then(() => { }));
// fixture.detectChanges(); });
// expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('My Example.pdf');
// }); /* tslint:disable:max-line-length */
// }); describe('MimeType handling', () => {
// })); it('should display a PDF file identified by mimetype when the filename has no extension', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
// return tcb
// it('Close button should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { .createAsync(ViewerComponent)
// return tcb .then((fixture) => {
// .createAsync(ViewerComponent) let component = fixture.componentInstance;
// .then((fixture) => { let element = fixture.nativeElement;
// let element = fixture.nativeElement; component.urlFile = 'content';
// let component = fixture.componentInstance; component.mimeType = 'application/pdf';
// component.urlFile = 'fake-url-file';
// component.ngOnChanges().then(() => {
// fixture.detectChanges(); fixture.detectChanges();
// expect(element.querySelector('pdf-viewer')).not.toBeNull();
// expect(element.querySelector('#viewer-close-button')).not.toBeNull(); });
// }); });
// })); }));
//
// it('Click on close button should hide the viewer', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { it('should display a PDF file identified by mimetype when the file extension is wrong', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
// return tcb return tcb
// .createAsync(ViewerComponent) .createAsync(ViewerComponent)
// .then((fixture) => { .then((fixture) => {
// let element = fixture.nativeElement; let component = fixture.componentInstance;
// let component = fixture.componentInstance; let element = fixture.nativeElement;
// component.urlFile = 'fake-url-file'; component.urlFile = 'content.bin';
// component.mimeType = 'application/pdf';
// fixture.detectChanges();
// element.querySelector('#viewer-close-button').click(); component.ngOnChanges().then(() => {
// fixture.detectChanges(); fixture.detectChanges();
// expect(element.querySelector('#viewer-main-container')).toBeNull(); expect(element.querySelector('pdf-viewer')).not.toBeNull();
// }); });
// })); });
// }); }));
//
// describe('Attribute', () => { it('should display an image file identified by mimetype when the filename has no extension', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
// it('Url File should be mandatory', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb
// return tcb .createAsync(ViewerComponent)
// .createAsync(ViewerComponent) .then((fixture) => {
// .then((fixture) => { let component = fixture.componentInstance;
// let component = fixture.componentInstance; let element = fixture.nativeElement;
// component.showViewer = true; component.urlFile = 'content';
// component.mimeType = 'image/png';
// expect(() => {
// component.ngOnChanges(); component.ngOnChanges().then(() => {
// }).toThrow(); fixture.detectChanges();
// }); expect(element.querySelector('#viewer-image')).not.toBeNull();
// })); });
// });
// it('showViewer default value should be true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { }));
// return tcb
// .createAsync(ViewerComponent) it('should display a image file identified by mimetype when the file extension is wrong', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
// .then((fixture) => { return tcb
// let component = fixture.componentInstance; .createAsync(ViewerComponent)
// .then((fixture) => {
// expect(component.showViewer).toBe(true); let component = fixture.componentInstance;
// }); let element = fixture.nativeElement;
// })); component.urlFile = 'content.bin';
// component.mimeType = 'image/png';
// it('if showViewer value is false the viewer should be hide', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
// return tcb component.ngOnChanges().then(() => {
// .createAsync(ViewerComponent) fixture.detectChanges();
// .then((fixture) => { expect(element.querySelector('#viewer-image')).not.toBeNull();
// 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();
// });
// });
// }));
// });
// });