mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-07 17:48:54 +00:00
Source Mapping is not working on test debugging (#1931)
* coverage single components run fix * remove spec.ts from coverage * make the coverage and the istanbul-instrumenter-loader works only over the console test because a problem on the remapping for the browser test * move tslint on the main folder of any component * remove build:w from readme * stop build tslint error also in spec files * clear karma file from unnecessary files * add set -f for build all script in order to accept * * fix lint problem and failing tests * fix failing test search component * add loader test for viewer * fix tslint error userinfo * --max_old_space_size=2048 remove * fix tslint error uploader unused EventEmitter * remove spec|index|.*mock|.*model|.*event from coverage
This commit is contained in:
committed by
Eugenio Romano
parent
ed30b74ce6
commit
282e64f93d
@@ -17,7 +17,7 @@
|
||||
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { TxtViewerComponent } from './txtViewer.component';
|
||||
import { DebugElement } from '@angular/core';
|
||||
import { DebugElement, SimpleChange } from '@angular/core';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
@@ -52,14 +52,22 @@ describe('Test ng2-alfresco-viewer Text View component', () => {
|
||||
debug = fixture.debugElement;
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
component.content = 'example';
|
||||
fixture.detectChanges();
|
||||
component.urlFile = require('../assets/fake-test-file.txt');
|
||||
});
|
||||
|
||||
|
||||
describe('View', () => {
|
||||
it('Should text container be present', () => {
|
||||
expect(element.querySelector('#adf-viewer-text-container').textContent).toContain('example');
|
||||
|
||||
it('Should text container be present with urlfile', (done) => {
|
||||
fixture.detectChanges();
|
||||
let change = new SimpleChange(null, null, true);
|
||||
|
||||
component.ngOnChanges(change).then(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#adf-viewer-text-container').textContent).toContain('example');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -16,7 +16,10 @@
|
||||
*/
|
||||
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { AlfrescoContentService } from 'ng2-alfresco-core';
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { ContentService } from 'ng2-alfresco-core';
|
||||
import { Http, Response, RequestOptions, ResponseContentType } from '@angular/http';
|
||||
import 'rxjs/add/operator/toPromise';
|
||||
|
||||
@Component({
|
||||
selector: 'txt-viewer',
|
||||
@@ -26,21 +29,39 @@ import { AlfrescoContentService } from 'ng2-alfresco-core';
|
||||
export class TxtViewerComponent {
|
||||
|
||||
@Input()
|
||||
nodeId: string;
|
||||
urlFile: any;
|
||||
|
||||
@Input()
|
||||
blobFile: any;
|
||||
|
||||
content: string;
|
||||
|
||||
constructor(private alfrescoContentService: AlfrescoContentService) {
|
||||
constructor(private http: Http, private contentService: ContentService) {
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.getNodeContent(this.nodeId);
|
||||
}
|
||||
ngOnChanges(changes: SimpleChange) {
|
||||
let blobFile = changes['blobFile'];
|
||||
if (blobFile && blobFile.currentValue) {
|
||||
this.urlFile = this.contentService.createTrustedUrl(this.blobFile);
|
||||
}
|
||||
if (!this.urlFile && !this.blobFile) {
|
||||
throw new Error('Attribute urlFile or blobFile is required');
|
||||
}
|
||||
|
||||
private getNodeContent(nodeId) {
|
||||
this.alfrescoContentService.getNodeContent(nodeId).subscribe((nodeContent) => {
|
||||
this.content = nodeContent;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.getUrlContent(resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
private getUrlContent(resolve, reject): void {
|
||||
this.http.get(this.urlFile, new RequestOptions({
|
||||
responseType: ResponseContentType.Text
|
||||
})).toPromise().then(
|
||||
(res: Response) => {
|
||||
this.content = res.text();
|
||||
resolve();
|
||||
}, (event) => {
|
||||
reject(event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@
|
||||
[nameFile]="displayName"></media-player>
|
||||
</div>
|
||||
<div class="center-element" *ngIf="isText()">
|
||||
<txt-viewer [nodeId]="fileNodeId" ></txt-viewer>
|
||||
<txt-viewer [urlFile]="urlFileContent" [blobFile]="blobFile" ></txt-viewer>
|
||||
</div>
|
||||
|
||||
<span *ngFor="let extensionTemplate of extensionTemplates">
|
||||
|
@@ -79,6 +79,7 @@ export class ViewerComponent {
|
||||
if (!this.urlFile && !this.blobFile && !this.fileNodeId) {
|
||||
throw new Error('Attribute urlFile or fileNodeId or blobFile is required');
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.blobFile) {
|
||||
this.mimeType = this.blobFile.type;
|
||||
@@ -201,7 +202,7 @@ export class ViewerComponent {
|
||||
if (this.mimeType && this.mimeType.indexOf('/')) {
|
||||
mimeExtension = this.mimeType.substr(this.mimeType.indexOf('/') + 1, this.mimeType.length);
|
||||
}
|
||||
return this.mimeType && (this.mimeType.indexOf('video/') || this.mimeType.indexOf('audio/')) === 0 && this.isMediaExtension(mimeExtension);
|
||||
return (this.mimeType && (this.mimeType.indexOf('video/') === 0 || this.mimeType.indexOf('audio/') === 0)) && this.isMediaExtension(mimeExtension);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user