[ADF-4647] download service (#4836)

* split download api into separate service

* move tests and fix code

* break dependency for thumbnail service

* update tests

* test fixes

* fix code

* fix unit tests
This commit is contained in:
Denys Vuika
2019-07-12 13:58:47 +01:00
committed by Eugenio Romano
parent d0d1154f84
commit a37f935c05
14 changed files with 231 additions and 103 deletions

View File

@@ -15,12 +15,14 @@
* limitations under the License.
*/
import { DataColumn, DataRow, DataSorting, ContentService, ThumbnailService } from '@alfresco/adf-core';
import { DataColumn, DataRow, DataSorting, ContentService, ThumbnailService, setupTestBed } from '@alfresco/adf-core';
import { FileNode, FolderNode, SmartFolderNode, RuleFolderNode, LinkFolderNode } from './../../mock';
import { ShareDataRow } from './share-data-row.model';
import { ShareDataTableAdapter } from './share-datatable-adapter';
import { DomSanitizer } from '@angular/platform-browser';
import { MatIconRegistry } from '@angular/material';
import { ContentTestingModule } from '../../testing/content.testing.module';
import { TestBed } from '@angular/core/testing';
class FakeSanitizer extends DomSanitizer {
@@ -57,12 +59,26 @@ describe('ShareDataTableAdapter', () => {
let thumbnailService: ThumbnailService;
let contentService: ContentService;
const fakeMatIconRegistry: MatIconRegistry = jasmine.createSpyObj(['addSvgIcon', 'addSvgIconInNamespace']);
setupTestBed({
imports: [ContentTestingModule],
providers: [
{
provide: MatIconRegistry,
useValue: jasmine.createSpyObj(['addSvgIcon', 'addSvgIconInNamespace'])
},
{
provide: DomSanitizer, useClass: FakeSanitizer
}
]
});
beforeEach(() => {
const imageUrl: string = 'http://<addresss>';
contentService = new ContentService(null, null, null, null);
thumbnailService = new ThumbnailService(contentService, fakeMatIconRegistry, new FakeSanitizer());
contentService = TestBed.get(ContentService);
thumbnailService = TestBed.get(ThumbnailService);
spyOn(thumbnailService, 'getDocumentThumbnailUrl').and.returnValue(imageUrl);
});

View File

@@ -16,13 +16,14 @@
*/
import { AlfrescoApiServiceMock, AppConfigService, ContentService,
setupTestBed, CoreModule, TranslationMock, StorageService
setupTestBed, CoreModule, TranslationMock, AlfrescoApiService, StorageService
} from '@alfresco/adf-core';
import { FileNode, FolderNode } from '../../mock';
import { ContentActionHandler } from '../models/content-action.model';
import { DocumentActionsService } from './document-actions.service';
import { DocumentListService } from './document-list.service';
import { of } from 'rxjs';
import { TestBed } from '@angular/core/testing';
describe('DocumentActionsService', () => {
@@ -30,14 +31,18 @@ describe('DocumentActionsService', () => {
let documentListService: DocumentListService;
setupTestBed({
imports: [
CoreModule.forRoot()
imports: [CoreModule.forRoot()],
providers: [
{
provide: AlfrescoApiService,
useValue: new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService())
}
]
});
beforeEach(() => {
const contentService = new ContentService(null, null, null, null);
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
const contentService = TestBed.get(ContentService);
documentListService = new DocumentListService(contentService, alfrescoApiService, null, null);
service = new DocumentActionsService(null, null, new TranslationMock(), documentListService, contentService);

View File

@@ -19,6 +19,7 @@ import { AlfrescoApiServiceMock, AlfrescoApiService,
AppConfigService, ContentService, setupTestBed, CoreModule, LogService, AppConfigServiceMock, StorageService } from '@alfresco/adf-core';
import { DocumentListService } from './document-list.service';
import { CustomResourcesService } from './custom-resources.service';
import { TestBed } from '@angular/core/testing';
declare let jasmine: any;
@@ -69,7 +70,7 @@ describe('DocumentListService', () => {
beforeEach(() => {
const logService = new LogService(new AppConfigServiceMock(null));
const contentService = new ContentService(null, null, null, null);
const contentService = TestBed.get(ContentService);
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
const customActionService = new CustomResourcesService(alfrescoApiService, logService);
service = new DocumentListService(contentService, alfrescoApiService, logService, customActionService);

View File

@@ -39,7 +39,7 @@ describe('FolderActionsService', () => {
const appConfig: AppConfigService = TestBed.get(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
const contentService = new ContentService(null, null, null, null);
const contentService = TestBed.get(ContentService);
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
documentListService = new DocumentListService(contentService, alfrescoApiService, null, null);
service = new FolderActionsService(null, documentListService, contentService, new TranslationMock());