[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

@@ -18,6 +18,9 @@
import { ChangeDetectorRef, Component, ElementRef, SimpleChange } from '@angular/core';
import { ContentService } from './../services/content.service';
import { CheckAllowableOperationDirective, NodeAllowableOperationSubject } from './check-allowable-operation.directive';
import { setupTestBed } from '../testing/setupTestBed';
import { CoreModule } from '../core.module';
import { TestBed } from '@angular/core/testing';
@Component({
selector: 'adf-text-subject'
@@ -30,6 +33,10 @@ describe('CheckAllowableOperationDirective', () => {
let changeDetectorMock: ChangeDetectorRef;
setupTestBed({
imports: [CoreModule.forRoot()]
});
beforeEach(() => {
changeDetectorMock = <ChangeDetectorRef> { detectChanges: () => {} };
});
@@ -101,7 +108,7 @@ describe('CheckAllowableOperationDirective', () => {
});
it('enables element when all nodes have expected permission', () => {
const contentService = new ContentService(null, null, null, null);
const contentService = TestBed.get(ContentService);
spyOn(contentService, 'hasAllowableOperations').and.returnValue(true);
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock);
@@ -114,7 +121,7 @@ describe('CheckAllowableOperationDirective', () => {
});
it('disables element when one of the nodes have no permission', () => {
const contentService = new ContentService(null, null, null, null);
const contentService = TestBed.get(ContentService);
spyOn(contentService, 'hasAllowableOperations').and.returnValue(false);
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock);
@@ -130,7 +137,7 @@ describe('CheckAllowableOperationDirective', () => {
describe('Angular component as subject', () => {
it('disables decorated component', () => {
const contentService = new ContentService(null, null, null, null);
const contentService = TestBed.get(ContentService);
spyOn(contentService, 'hasAllowableOperations').and.returnValue(false);
spyOn(changeDetectorMock, 'detectChanges');
@@ -146,7 +153,7 @@ describe('CheckAllowableOperationDirective', () => {
});
it('enables decorated component', () => {
const contentService = new ContentService(null, null, null, null);
const contentService = TestBed.get(ContentService);
spyOn(contentService, 'hasAllowableOperations').and.returnValue(true);
spyOn(changeDetectorMock, 'detectChanges');