prepare tests for ng-12 upgrade (#7099)

* prepare tests for ng12 upgrade

* fix lint

* fix tests

* test fixes

* fix code and tests

* fix code and tests

* test fixes

* test fixes
This commit is contained in:
Denys Vuika
2021-06-11 07:36:32 +01:00
committed by GitHub
parent 558056b05c
commit eb71a79d1e
112 changed files with 982 additions and 1057 deletions

View File

@@ -22,7 +22,7 @@ import { setupTestBed } from '../../testing/setup-test-bed';
import { CoreTestingModule } from '../../testing/core.testing.module';
import { TranslateModule } from '@ngx-translate/core';
import { AlfrescoApiService } from '../../services';
import { NodeEntry } from '@alfresco/js-api';
import { NodeEntry, RenditionPaging } from '@alfresco/js-api';
describe('Test Media player component ', () => {
@@ -52,13 +52,13 @@ describe('Test Media player component ', () => {
it('should generate tracks for media file when webvtt rendition exists', fakeAsync(() => {
const fakeRenditionUrl = 'http://fake.rendition.url';
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValues(
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } }))
);
spyOn(alfrescoApiService.renditionsApi, 'getRenditions').and.returnValues(
{ list: { entries: [{ entry: { id: 'webvtt', status: 'CREATED' } }] } }
spyOn(alfrescoApiService.renditionsApi, 'getRenditions').and.returnValue(
Promise.resolve(new RenditionPaging({ list: { entries: [{ entry: { id: 'webvtt', status: 'CREATED' } }] } }))
);
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValues('http://iam-fake.url');
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValue('http://iam-fake.url');
spyOn(alfrescoApiService.contentApi, 'getRenditionUrl').and.returnValue(fakeRenditionUrl);
component.ngOnChanges(change);
@@ -68,15 +68,15 @@ describe('Test Media player component ', () => {
}));
it('should not generate tracks for media file when webvtt rendition is not created', fakeAsync(() => {
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValues(
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } }))
);
spyOn(alfrescoApiService.renditionsApi, 'getRenditions').and.returnValues(
{ list: { entries: [{ entry: { id: 'webvtt', status: 'NOT_CREATED' } }] } }
spyOn(alfrescoApiService.renditionsApi, 'getRenditions').and.returnValue(
Promise.resolve(new RenditionPaging({ list: { entries: [{ entry: { id: 'webvtt', status: 'NOT_CREATED' } }] } }))
);
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValues('http://iam-fake.url');
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValue('http://iam-fake.url');
component.ngOnChanges(change);
tick();
@@ -85,15 +85,15 @@ describe('Test Media player component ', () => {
}));
it('should not generate tracks for media file when webvtt rendition does not exist', fakeAsync(() => {
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValues(
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } }))
);
spyOn(alfrescoApiService.renditionsApi, 'getRenditions').and.returnValues(
{ list: { entries: [] } }
spyOn(alfrescoApiService.renditionsApi, 'getRenditions').and.returnValue(
Promise.resolve(new RenditionPaging({ list: { entries: [] } }))
);
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValues('http://iam-fake.url');
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValue('http://iam-fake.url');
component.ngOnChanges(change);
tick();

View File

@@ -337,13 +337,13 @@ describe('Test PdfViewer component', () => {
if (context.data.reason === pdfjsLib.PasswordResponses.NEED_PASSWORD) {
return {
afterClosed: () => of('wrong_password')
};
} as any;
}
if (context.data.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
return {
afterClosed: () => of('password')
};
} as any;
}
return undefined;
@@ -404,7 +404,7 @@ describe('Test PdfViewer component', () => {
done();
return of('');
}
};
} as any;
});
spyOn(componentUrlTestPasswordComponent.pdfViewerComponent.close, 'emit');

View File

@@ -293,7 +293,7 @@ describe('ViewerComponent', () => {
const displayName = 'the-name';
const nodeDetails = { name: displayName, id: '12' };
const contentUrl = '/content/url/path';
const alfrescoApiInstanceMock = {
const alfrescoApiInstanceMock: any = {
nodes: {
getNodeInfo: () => Promise.resolve(nodeDetails),
getNode: () => Promise.resolve({ id: 'fake-node', entry: { content: {} } })
@@ -687,7 +687,7 @@ describe('ViewerComponent', () => {
const node = new NodeEntry({ entry: { name: displayName, id: '12', content: { mimeType: 'txt' } } });
const nodeDetails = { name: displayName, id: '12', content: { mimeType: 'txt' } };
const contentUrl = '/content/url/path';
const alfrescoApiInstanceMock = {
const alfrescoApiInstanceMock: any = {
nodes: {
getNodeInfo: () => Promise.resolve(nodeDetails),
getNode: () => Promise.resolve(node)
@@ -1066,7 +1066,7 @@ describe('ViewerComponent', () => {
const displayName = 'the-name';
const nodeDetails = new NodeEntry({ entry: { name: displayName, id: '12', content: { mimeType: 'txt' } } });
const contentUrl = '/content/url/path';
const alfrescoApiInstanceMock = {
const alfrescoApiInstanceMock: any = {
nodes: {
getNode: () => Promise.resolve(nodeDetails)
},