mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-686] add blobFile as input (#1933)
This commit is contained in:
committed by
Eugenio Romano
parent
033c0f0a6b
commit
23fbc8f858
@@ -22,12 +22,14 @@ import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
CoreModule
|
||||
CoreModule,
|
||||
ContentService
|
||||
} from 'ng2-alfresco-core';
|
||||
|
||||
describe('Test ng2-alfresco-viewer Not Supported Format View component', () => {
|
||||
|
||||
let component: NotSupportedFormat;
|
||||
let service: ContentService;
|
||||
let fixture: ComponentFixture<NotSupportedFormat>;
|
||||
let debug: DebugElement;
|
||||
let element: HTMLElement;
|
||||
@@ -41,14 +43,15 @@ describe('Test ng2-alfresco-viewer Not Supported Format View component', () => {
|
||||
providers: [
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoApiService
|
||||
AlfrescoApiService,
|
||||
ContentService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NotSupportedFormat);
|
||||
|
||||
service = fixture.debugElement.injector.get(ContentService);
|
||||
debug = fixture.debugElement;
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
@@ -71,11 +74,23 @@ describe('Test ng2-alfresco-viewer Not Supported Format View component', () => {
|
||||
describe('User Interaction', () => {
|
||||
it('should call download method if Click on Download button', () => {
|
||||
spyOn(window, 'open');
|
||||
component.urlFile = 'test';
|
||||
|
||||
let downloadButton: any = element.querySelector('#viewer-download-button');
|
||||
downloadButton.click();
|
||||
|
||||
expect(window.open).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call content service download method if Click on Download button', () => {
|
||||
spyOn(service, 'downloadBlob');
|
||||
|
||||
component.blobFile = new Blob();
|
||||
|
||||
let downloadButton: any = element.querySelector('#viewer-download-button');
|
||||
downloadButton.click();
|
||||
|
||||
expect(service.downloadBlob).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { ContentService } from 'ng2-alfresco-core';
|
||||
|
||||
@Component({
|
||||
selector: 'not-supported-format',
|
||||
@@ -30,10 +31,21 @@ export class NotSupportedFormat {
|
||||
@Input()
|
||||
urlFile: string;
|
||||
|
||||
@Input()
|
||||
blobFile: Blob;
|
||||
|
||||
constructor(private contentService: ContentService) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file opening it in a new window
|
||||
*/
|
||||
download() {
|
||||
window.open(this.urlFile);
|
||||
if (this.urlFile) {
|
||||
window.open(this.urlFile);
|
||||
} else {
|
||||
this.contentService.downloadBlob(this.blobFile, this.nameFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@
|
||||
</span>
|
||||
|
||||
<div *ngIf="!supportedExtension()">
|
||||
<not-supported-format *ngIf="!extensionTemplate" [urlFile]="urlFileContent" [nameFile]="displayName"></not-supported-format>
|
||||
<not-supported-format *ngIf="!extensionTemplate" [urlFile]="urlFileContent" [blobFile]="blobFile" [nameFile]="displayName"></not-supported-format>
|
||||
</div>
|
||||
<!-- End View Switch -->
|
||||
|
||||
|
Reference in New Issue
Block a user