mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
Clean pdf viewer unit (#4916)
* fix unit test pdf viewer * add more clean unit test core * add more clean unit test core * Delete license-info-3.3.0.md
This commit is contained in:
parent
3d336bf9bd
commit
7a70e88ae3
@ -1,6 +1,8 @@
|
|||||||
|
var PROXY_HOST_ADF = process.env.PROXY_HOST_ADF;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"/alfresco": {
|
"/alfresco": {
|
||||||
"target": "http://localhost:8080",
|
"target": (PROXY_HOST_ADF || "http://localhost:8080"),
|
||||||
"secure": false,
|
"secure": false,
|
||||||
"pathRewrite": {
|
"pathRewrite": {
|
||||||
"^/alfresco/alfresco": ""
|
"^/alfresco/alfresco": ""
|
||||||
@ -15,7 +17,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/activiti-app": {
|
"/activiti-app": {
|
||||||
"target": "http://localhost:8080",
|
"target": (PROXY_HOST_ADF || "http://localhost:8080"),
|
||||||
"secure": false,
|
"secure": false,
|
||||||
"pathRewrite": {
|
"pathRewrite": {
|
||||||
"^/activiti-app/activiti-app": ""
|
"^/activiti-app/activiti-app": ""
|
||||||
|
@ -100,7 +100,7 @@ describe('DateTimeWidgetComponent', () => {
|
|||||||
|
|
||||||
widget.field = field;
|
widget.field = field;
|
||||||
|
|
||||||
widget.onDateChanged({ value: moment('2008-09-15T15:53:00') });
|
widget.onDateChanged({ value: moment('1982-03-13T10:00:000Z') });
|
||||||
expect(widget.onFieldChanged).toHaveBeenCalledWith(field);
|
expect(widget.onFieldChanged).toHaveBeenCalledWith(field);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ module.exports = function (config) {
|
|||||||
{pattern: 'lib/config/app.config.json', included: false, served: true, watched: false},
|
{pattern: 'lib/config/app.config.json', included: false, served: true, watched: false},
|
||||||
{pattern: 'lib/core/viewer/assets/fake-test-file.pdf', included: false, served: true, watched: false},
|
{pattern: 'lib/core/viewer/assets/fake-test-file.pdf', included: false, served: true, watched: false},
|
||||||
{pattern: 'lib/core/viewer/assets/fake-test-file.txt', included: false, served: true, watched: false},
|
{pattern: 'lib/core/viewer/assets/fake-test-file.txt', included: false, served: true, watched: false},
|
||||||
|
{pattern: 'lib/core/viewer/assets/fake-test-video.mp4', included: false, served: true, watched: false},
|
||||||
{
|
{
|
||||||
pattern: 'lib/core//viewer/assets/fake-test-password-file.pdf',
|
pattern: 'lib/core//viewer/assets/fake-test-password-file.pdf',
|
||||||
included: false,
|
included: false,
|
||||||
@ -63,8 +64,15 @@ module.exports = function (config) {
|
|||||||
'/assets/adf-core/i18n/en-GB.json': '/base/lib/core/i18n/en.json',
|
'/assets/adf-core/i18n/en-GB.json': '/base/lib/core/i18n/en.json',
|
||||||
'/assets/adf-core/i18n/en-US.json': '/base/lib/core/i18n/en.json',
|
'/assets/adf-core/i18n/en-US.json': '/base/lib/core/i18n/en.json',
|
||||||
'/app.config.json': '/base/lib/config/app.config.json',
|
'/app.config.json': '/base/lib/config/app.config.json',
|
||||||
|
'/fake-content-img' : '/base/lib/core/assets/images/logo.png',
|
||||||
|
'/fake-content-img.bin' : '/base/lib/core/assets/images/logo.png',
|
||||||
'/fake-test-file.pdf': '/base/lib/core/viewer/assets/fake-test-file.pdf',
|
'/fake-test-file.pdf': '/base/lib/core/viewer/assets/fake-test-file.pdf',
|
||||||
|
'/fake-content-pdf': '/base/lib/core/viewer/assets/fake-test-file.pdf',
|
||||||
|
'/fake-content-pdf.bin': '/base/lib/core/viewer/assets/fake-test-file.pdf',
|
||||||
'/fake-test-file.txt': '/base/lib/core/viewer/assets/fake-test-file.txt',
|
'/fake-test-file.txt': '/base/lib/core/viewer/assets/fake-test-file.txt',
|
||||||
|
'/fake-content-video.bin': '/base/lib/core/viewer/assets/fake-test-video.mp4',
|
||||||
|
'/fake-content-video': '/base/lib/core/viewer/assets/fake-test-video.mp4',
|
||||||
|
'/fake-content-txt.bin': '/base/lib/core/viewer/assets/fake-test-file.txt',
|
||||||
'/fake-test-password-file.pdf': '/base/lib/core/viewer/assets/fake-test-password-file.pdf'
|
'/fake-test-password-file.pdf': '/base/lib/core/viewer/assets/fake-test-password-file.pdf'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import { NodePaging, QueryBody } from '@alfresco/js-api';
|
|||||||
import { Observable, Subject, from, throwError } from 'rxjs';
|
import { Observable, Subject, from, throwError } from 'rxjs';
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
import { SearchConfigurationService } from './search-configuration.service';
|
import { SearchConfigurationService } from './search-configuration.service';
|
||||||
import { catchError } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -44,11 +43,9 @@ export class SearchService {
|
|||||||
|
|
||||||
promise.then((nodePaging: NodePaging) => {
|
promise.then((nodePaging: NodePaging) => {
|
||||||
this.dataLoaded.next(nodePaging);
|
this.dataLoaded.next(nodePaging);
|
||||||
});
|
}).catch((err) => this.handleError(err));
|
||||||
|
|
||||||
return from(promise).pipe(
|
return from(promise);
|
||||||
catchError((err) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,11 +61,9 @@ export class SearchService {
|
|||||||
|
|
||||||
promise.then((nodePaging: NodePaging) => {
|
promise.then((nodePaging: NodePaging) => {
|
||||||
this.dataLoaded.next(nodePaging);
|
this.dataLoaded.next(nodePaging);
|
||||||
});
|
}).catch((err) => this.handleError(err));
|
||||||
|
|
||||||
return from(promise).pipe(
|
return from(promise);
|
||||||
catchError((err) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,11 +76,9 @@ export class SearchService {
|
|||||||
|
|
||||||
promise.then((nodePaging: NodePaging) => {
|
promise.then((nodePaging: NodePaging) => {
|
||||||
this.dataLoaded.next(nodePaging);
|
this.dataLoaded.next(nodePaging);
|
||||||
});
|
}).catch((err) => this.handleError(err));
|
||||||
|
|
||||||
return from(promise).pipe(
|
return from(promise);
|
||||||
catchError((err: any) => this.handleError(err))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleError(error: any): Observable<any> {
|
private handleError(error: any): Observable<any> {
|
||||||
|
BIN
lib/core/viewer/assets/fake-test-video.mp4
Normal file
BIN
lib/core/viewer/assets/fake-test-video.mp4
Normal file
Binary file not shown.
@ -165,6 +165,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should Loader be present', () => {
|
it('should Loader be present', () => {
|
||||||
expect(element.querySelector('.adf-loader-container')).not.toBeNull();
|
expect(element.querySelector('.adf-loader-container')).not.toBeNull();
|
||||||
});
|
});
|
||||||
@ -206,18 +207,18 @@ describe('Test PdfViewer component', () => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
document.body.removeChild(elementUrlTestComponent);
|
document.body.removeChild(elementUrlTestComponent);
|
||||||
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should Canvas be present', fakeAsync(() => {
|
it('should Canvas be present', (done) => {
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
|
|
||||||
tick(250);
|
|
||||||
|
|
||||||
fixtureUrlTestComponent.whenStable().then(() => {
|
fixtureUrlTestComponent.whenStable().then(() => {
|
||||||
expect(elementUrlTestComponent.querySelector('.adf-pdfViewer')).not.toBeNull();
|
expect(elementUrlTestComponent.querySelector('.adf-pdfViewer')).not.toBeNull();
|
||||||
expect(elementUrlTestComponent.querySelector('.adf-viewer-pdf-viewer')).not.toBeNull();
|
expect(elementUrlTestComponent.querySelector('.adf-viewer-pdf-viewer')).not.toBeNull();
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}));
|
}, 25000);
|
||||||
|
|
||||||
it('should Next an Previous Buttons be present', (done) => {
|
it('should Next an Previous Buttons be present', (done) => {
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
@ -226,7 +227,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(elementUrlTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
expect(elementUrlTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should Input Page elements be present', (done) => {
|
it('should Input Page elements be present', (done) => {
|
||||||
|
|
||||||
@ -240,7 +241,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(elementUrlTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
expect(elementUrlTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should Toolbar be hide if showToolbar is false', (done) => {
|
it('should Toolbar be hide if showToolbar is false', (done) => {
|
||||||
component.showToolbar = false;
|
component.showToolbar = false;
|
||||||
@ -251,7 +252,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(elementUrlTestComponent.querySelector('.viewer-toolbar-pagination')).toBeNull();
|
expect(elementUrlTestComponent.querySelector('.viewer-toolbar-pagination')).toBeNull();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('View with blob file', () => {
|
describe('View with blob file', () => {
|
||||||
@ -276,6 +277,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
document.body.removeChild(elementBlobTestComponent);
|
document.body.removeChild(elementBlobTestComponent);
|
||||||
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should Canvas be present', () => {
|
it('should Canvas be present', () => {
|
||||||
@ -287,14 +289,15 @@ describe('Test PdfViewer component', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should Next an Previous Buttons be present', () => {
|
it('should Next an Previous Buttons be present', (done) => {
|
||||||
fixtureBlobTestComponent.detectChanges();
|
fixtureBlobTestComponent.detectChanges();
|
||||||
|
|
||||||
fixtureBlobTestComponent.whenStable().then(() => {
|
fixtureBlobTestComponent.whenStable().then(() => {
|
||||||
expect(elementBlobTestComponent.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
expect(elementBlobTestComponent.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||||
expect(elementBlobTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
expect(elementBlobTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
}, 25000);
|
||||||
|
|
||||||
it('should Input Page elements be present', (done) => {
|
it('should Input Page elements be present', (done) => {
|
||||||
fixtureBlobTestComponent.detectChanges();
|
fixtureBlobTestComponent.detectChanges();
|
||||||
@ -308,7 +311,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(elementBlobTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
expect(elementBlobTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should Toolbar be hide if showToolbar is false', (done) => {
|
it('should Toolbar be hide if showToolbar is false', (done) => {
|
||||||
componentBlobTestComponent.pdfViewerComponent.showToolbar = false;
|
componentBlobTestComponent.pdfViewerComponent.showToolbar = false;
|
||||||
@ -320,7 +323,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(elementBlobTestComponent.querySelector('.viewer-toolbar-pagination')).toBeNull();
|
expect(elementBlobTestComponent.querySelector('.viewer-toolbar-pagination')).toBeNull();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Password protection dialog', () => {
|
describe('Password protection dialog', () => {
|
||||||
@ -421,7 +424,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(componentUrlTestComponent.pdfViewerComponent.totalPages).toBe(6);
|
expect(componentUrlTestComponent.pdfViewerComponent.totalPages).toBe(6);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should nextPage move to the next page', (done) => {
|
it('should nextPage move to the next page', (done) => {
|
||||||
const nextPageButton: any = elementUrlTestComponent.querySelector('#viewer-next-page-button');
|
const nextPageButton: any = elementUrlTestComponent.querySelector('#viewer-next-page-button');
|
||||||
@ -433,7 +436,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should event RIGHT_ARROW keyboard change pages', (done) => {
|
it('should event RIGHT_ARROW keyboard change pages', (done) => {
|
||||||
EventMock.keyDown(RIGHT_ARROW);
|
EventMock.keyDown(RIGHT_ARROW);
|
||||||
@ -445,7 +448,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should event LEFT_ARROW keyboard change pages', (done) => {
|
it('should event LEFT_ARROW keyboard change pages', (done) => {
|
||||||
component.inputPage('2');
|
component.inputPage('2');
|
||||||
@ -462,7 +465,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should previous page move to the previous page', (done) => {
|
it('should previous page move to the previous page', (done) => {
|
||||||
const previousPageButton: any = elementUrlTestComponent.querySelector('#viewer-previous-page-button');
|
const previousPageButton: any = elementUrlTestComponent.querySelector('#viewer-previous-page-button');
|
||||||
@ -477,7 +480,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should previous page not move to the previous page if is page 1', (done) => {
|
it('should previous page not move to the previous page if is page 1', (done) => {
|
||||||
component.previousPage();
|
component.previousPage();
|
||||||
@ -487,7 +490,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(1);
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(1);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should Input page move to the inserted page', (done) => {
|
it('should Input page move to the inserted page', (done) => {
|
||||||
componentUrlTestComponent.pdfViewerComponent.inputPage('2');
|
componentUrlTestComponent.pdfViewerComponent.inputPage('2');
|
||||||
@ -497,7 +500,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
describe('Resize interaction', () => {
|
describe('Resize interaction', () => {
|
||||||
|
|
||||||
@ -510,7 +513,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
}, 5000);
|
}, 25000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Thumbnails', () => {
|
describe('Thumbnails', () => {
|
||||||
@ -522,7 +525,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(componentUrlTestComponent.pdfViewerComponent.pdfThumbnailsContext.viewer).not.toBeNull();
|
expect(componentUrlTestComponent.pdfViewerComponent.pdfThumbnailsContext.viewer).not.toBeNull();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should open thumbnails panel', (done) => {
|
it('should open thumbnails panel', (done) => {
|
||||||
expect(elementUrlTestComponent.querySelector('.adf-pdf-viewer__thumbnails')).toBeNull();
|
expect(elementUrlTestComponent.querySelector('.adf-pdf-viewer__thumbnails')).toBeNull();
|
||||||
@ -535,7 +538,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
expect(elementUrlTestComponent.querySelector('.adf-pdf-viewer__thumbnails')).not.toBeNull();
|
expect(elementUrlTestComponent.querySelector('.adf-pdf-viewer__thumbnails')).not.toBeNull();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Viewer events', () => {
|
describe('Viewer events', () => {
|
||||||
@ -560,7 +563,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
it('should react on the emit of pagesLoaded event', (done) => {
|
it('should react on the emit of pagesLoaded event', (done) => {
|
||||||
fixtureUrlTestComponent.detectChanges();
|
fixtureUrlTestComponent.detectChanges();
|
||||||
@ -583,7 +586,7 @@ describe('Test PdfViewer component', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 25000);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -181,6 +181,10 @@ describe('ViewerComponent', () => {
|
|||||||
|
|
||||||
describe('Extension Type Test', () => {
|
describe('Extension Type Test', () => {
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
fixture.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
it('should extension file pdf be loaded', (done) => {
|
it('should extension file pdf be loaded', (done) => {
|
||||||
component.urlFile = 'fake-test-file.pdf';
|
component.urlFile = 'fake-test-file.pdf';
|
||||||
component.ngOnChanges(null);
|
component.ngOnChanges(null);
|
||||||
@ -269,34 +273,12 @@ describe('ViewerComponent', () => {
|
|||||||
|
|
||||||
describe('MimeType handling', () => {
|
describe('MimeType handling', () => {
|
||||||
|
|
||||||
it('should display a PDF file identified by mimetype when the filename has no extension', (done) => {
|
afterEach(() => {
|
||||||
component.urlFile = 'content';
|
fixture.destroy();
|
||||||
component.mimeType = 'application/pdf';
|
|
||||||
fixture.detectChanges();
|
|
||||||
component.ngOnChanges(null);
|
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(element.querySelector('adf-pdf-viewer')).not.toBeNull();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display a PDF file identified by mimetype when the file extension is wrong', (done) => {
|
|
||||||
component.urlFile = 'content.bin';
|
|
||||||
component.mimeType = 'application/pdf';
|
|
||||||
component.ngOnChanges(null);
|
|
||||||
fixture.detectChanges();
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(element.querySelector('adf-pdf-viewer')).not.toBeNull();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display an image file identified by mimetype when the filename has no extension', (done) => {
|
it('should display an image file identified by mimetype when the filename has no extension', (done) => {
|
||||||
component.urlFile = 'content';
|
component.urlFile = 'fake-content-img';
|
||||||
component.mimeType = 'image/png';
|
component.mimeType = 'image/png';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.ngOnChanges(null);
|
component.ngOnChanges(null);
|
||||||
@ -309,7 +291,7 @@ describe('ViewerComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should display a image file identified by mimetype when the file extension is wrong', (done) => {
|
it('should display a image file identified by mimetype when the file extension is wrong', (done) => {
|
||||||
component.urlFile = 'content.bin';
|
component.urlFile = 'fake-content-img.bin';
|
||||||
component.mimeType = 'image/png';
|
component.mimeType = 'image/png';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.ngOnChanges(null);
|
component.ngOnChanges(null);
|
||||||
@ -321,21 +303,8 @@ describe('ViewerComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display the media player if the file identified by mimetype is a media when the filename has wrong extension', (done) => {
|
|
||||||
component.urlFile = 'content.bin';
|
|
||||||
component.mimeType = 'video/mp4';
|
|
||||||
fixture.detectChanges();
|
|
||||||
component.ngOnChanges(null);
|
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(element.querySelector('adf-media-player')).not.toBeNull();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display the txt viewer if the file identified by mimetype is a txt when the filename has wrong extension', (done) => {
|
it('should display the txt viewer if the file identified by mimetype is a txt when the filename has wrong extension', (done) => {
|
||||||
component.urlFile = 'content.bin';
|
component.urlFile = 'fake-content-txt.bin';
|
||||||
component.mimeType = 'text/plain';
|
component.mimeType = 'text/plain';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.ngOnChanges(null);
|
component.ngOnChanges(null);
|
||||||
@ -347,19 +316,6 @@ describe('ViewerComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('should display the media player if the file identified by mimetype is a media when the filename has no extension', (done) => {
|
|
||||||
component.urlFile = 'content';
|
|
||||||
component.mimeType = 'video/mp4';
|
|
||||||
fixture.detectChanges();
|
|
||||||
component.ngOnChanges(null);
|
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(element.querySelector('adf-media-player')).not.toBeNull();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should node without content show unkonwn', (done) => {
|
it('should node without content show unkonwn', (done) => {
|
||||||
const displayName = 'the-name';
|
const displayName = 'the-name';
|
||||||
const nodeDetails = { name: displayName, id: '12' };
|
const nodeDetails = { name: displayName, id: '12' };
|
||||||
@ -367,7 +323,7 @@ describe('ViewerComponent', () => {
|
|||||||
const alfrescoApiInstanceMock = {
|
const alfrescoApiInstanceMock = {
|
||||||
nodes: {
|
nodes: {
|
||||||
getNodeInfo: () => Promise.resolve(nodeDetails),
|
getNodeInfo: () => Promise.resolve(nodeDetails),
|
||||||
getNode: () => Promise.resolve({ id: 'fake-node' })
|
getNode: () => Promise.resolve({ id: 'fake-node', entry: { content: {} } })
|
||||||
},
|
},
|
||||||
content: { getContentUrl: () => contentUrl }
|
content: { getContentUrl: () => contentUrl }
|
||||||
};
|
};
|
||||||
@ -385,6 +341,58 @@ describe('ViewerComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should display the media player if the file identified by mimetype is a media when the filename has wrong extension', (done) => {
|
||||||
|
component.urlFile = 'fake-content-video.bin';
|
||||||
|
component.mimeType = 'video/mp4';
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges(null);
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(element.querySelector('adf-media-player')).not.toBeNull();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}, 25000);
|
||||||
|
|
||||||
|
it('should display the media player if the file identified by mimetype is a media when the filename has no extension', (done) => {
|
||||||
|
component.urlFile = 'fake-content-video';
|
||||||
|
component.mimeType = 'video/mp4';
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges(null);
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(element.querySelector('adf-media-player')).not.toBeNull();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}, 25000);
|
||||||
|
|
||||||
|
it('should display a PDF file identified by mimetype when the filename has no extension', (done) => {
|
||||||
|
component.urlFile = 'fake-content-pdf';
|
||||||
|
component.mimeType = 'application/pdf';
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges(null);
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(element.querySelector('adf-pdf-viewer')).not.toBeNull();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
}, 25000);
|
||||||
|
|
||||||
|
it('should display a PDF file identified by mimetype when the file extension is wrong', (done) => {
|
||||||
|
component.urlFile = 'fake-content-pdf.bin';
|
||||||
|
component.mimeType = 'application/pdf';
|
||||||
|
component.ngOnChanges(null);
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(element.querySelector('adf-pdf-viewer')).not.toBeNull();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}, 25000);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change display name every time node changes', fakeAsync(() => {
|
it('should change display name every time node changes', fakeAsync(() => {
|
||||||
|
2754
package-lock.json
generated
2754
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -109,7 +109,7 @@
|
|||||||
"moment-es6": "^1.0.0",
|
"moment-es6": "^1.0.0",
|
||||||
"ng2-charts": "1.6.0",
|
"ng2-charts": "1.6.0",
|
||||||
"ngx-monaco-editor": "^7.0.0",
|
"ngx-monaco-editor": "^7.0.0",
|
||||||
"pdfjs-dist": "^2.0.489",
|
"pdfjs-dist": "2.0.489",
|
||||||
"raphael": "2.2.7",
|
"raphael": "2.2.7",
|
||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
"remark-validate-links": "^8.0.0",
|
"remark-validate-links": "^8.0.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user