mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-01 14:41:32 +00:00
Retroactively add mimeType property into and tests
This commit is contained in:
@@ -109,7 +109,8 @@ Attribute | Options | Default | Description | Mandatory
|
||||
`urlFile` | *string* | | Url where to load the file | mandatory
|
||||
`fileName` | *string* | Parsed from `urlFile` | Name of the file to display in the title bar. If not specified will take the last part of the URL |
|
||||
`overlayMode` | *boolean* | `false` | if true Show the Viewer full page over the present content |
|
||||
`showViewer` | *boolean* | `true` | Hide o show the viewer |
|
||||
`showViewer` | *boolean* | `true` | Hide or show the viewer |
|
||||
`mimeType` | *string* | `true` | MimeType of the file, used to detect if the browser can display the content. If not supplied the component will attempt to guess based on file extension of the `urlFile` |
|
||||
|
||||
|
||||
|
||||
|
@@ -215,4 +215,71 @@ describe('ViewerComponent', () => {
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
/* 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();
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user