mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3912] Improved folder retrieving for DL (#4423)
* [ADF-3912] added abstract class for document-list component to be provided * [ADF-3912] - created abstract class for document-list service * [ADF-3912] - fixing and removing the custom resource from document-list * [ADF-3912] added interface for document list service * [ADF-3912] added interface for loadFolderById for DL component * [ADF-3912] fixed missing return type * [ADF-3912] removed comment * [ADF-3912] fixed PR comments * [ADF-3912] fixed wrong import * [ADF-3912] fixed unit test failing * [ADF-3912] removed unused method * [ADF-3912] fixed lint problems
This commit is contained in:
@@ -20,25 +20,29 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PathElementEntity } from '@alfresco/js-api';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { fakeNodeWithCreatePermission } from '../mock';
|
||||
import { DocumentListComponent } from '../document-list';
|
||||
import { DocumentListComponent, DocumentListService } from '../document-list';
|
||||
import { BreadcrumbComponent } from './breadcrumb.component';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Breadcrumb', () => {
|
||||
|
||||
let component: BreadcrumbComponent;
|
||||
let fixture: ComponentFixture<BreadcrumbComponent>;
|
||||
let documentList: DocumentListComponent;
|
||||
let documentListService: DocumentListService = jasmine.createSpyObj({'loadFolderByNodeId' : of(''), 'isCustomSourceService': false});
|
||||
let documentListComponent: DocumentListComponent;
|
||||
|
||||
setupTestBed({
|
||||
imports: [ContentTestingModule],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
providers : [{ provide: DocumentListService, useValue: documentListService }]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BreadcrumbComponent);
|
||||
component = fixture.componentInstance;
|
||||
documentList = TestBed.createComponent<DocumentListComponent>(DocumentListComponent).componentInstance;
|
||||
documentListComponent = TestBed.createComponent<DocumentListComponent>(DocumentListComponent).componentInstance;
|
||||
documentListService = TestBed.get(DocumentListService);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -69,17 +73,17 @@ describe('Breadcrumb', () => {
|
||||
component.onRoutePathClick(node, null);
|
||||
});
|
||||
|
||||
it('should update document list on click', (done) => {
|
||||
spyOn(documentList, 'loadFolderByNodeId').and.stub();
|
||||
it('should update document list on click', () => {
|
||||
|
||||
const node = <PathElementEntity> { id: '-id-', name: 'name' };
|
||||
component.target = documentList;
|
||||
component.target = documentListComponent;
|
||||
|
||||
component.onRoutePathClick(node, null);
|
||||
setTimeout(() => {
|
||||
expect(documentList.loadFolderByNodeId).toHaveBeenCalledWith(node.id);
|
||||
done();
|
||||
}, 0);
|
||||
|
||||
expect(documentListService.loadFolderByNodeId).toHaveBeenCalledWith(node.id,
|
||||
documentListComponent.DEFAULT_PAGINATION,
|
||||
documentListComponent.includeFields,
|
||||
documentListComponent.where);
|
||||
});
|
||||
|
||||
it('should not parse the route when node not provided', () => {
|
||||
|
@@ -20,25 +20,29 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { fakeNodeWithCreatePermission } from '../mock';
|
||||
import { DocumentListComponent } from '../document-list';
|
||||
import { DocumentListComponent, DocumentListService } from '../document-list';
|
||||
import { DropdownBreadcrumbComponent } from './dropdown-breadcrumb.component';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('DropdownBreadcrumb', () => {
|
||||
|
||||
let component: DropdownBreadcrumbComponent;
|
||||
let fixture: ComponentFixture<DropdownBreadcrumbComponent>;
|
||||
let documentList: DocumentListComponent;
|
||||
let documentListService: DocumentListService = jasmine.createSpyObj({'loadFolderByNodeId' : of(''), 'isCustomSourceService': false});
|
||||
|
||||
setupTestBed({
|
||||
imports: [ContentTestingModule],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
providers : [{ provide: DocumentListService, useValue: documentListService }]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(DropdownBreadcrumbComponent);
|
||||
component = fixture.componentInstance;
|
||||
documentList = TestBed.createComponent<DocumentListComponent>(DocumentListComponent).componentInstance;
|
||||
documentListService = TestBed.get(DocumentListService);
|
||||
}));
|
||||
|
||||
afterEach(async(() => {
|
||||
@@ -151,7 +155,6 @@ describe('DropdownBreadcrumb', () => {
|
||||
});
|
||||
|
||||
it('should update document list when clicking on an option', (done) => {
|
||||
spyOn(documentList, 'loadFolderByNodeId').and.stub();
|
||||
component.target = documentList;
|
||||
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
fakeNodeWithCreatePermissionInstance.path.elements = [{ id: '1', name: 'Stark Industries' }];
|
||||
@@ -160,10 +163,9 @@ describe('DropdownBreadcrumb', () => {
|
||||
fixture.whenStable().then(() => {
|
||||
openSelect();
|
||||
fixture.whenStable().then(() => {
|
||||
|
||||
clickOnTheFirstOption();
|
||||
|
||||
expect(documentList.loadFolderByNodeId).toHaveBeenCalledWith('1');
|
||||
expect(documentListService.loadFolderByNodeId).toHaveBeenCalledWith('1', documentList.DEFAULT_PAGINATION, undefined, undefined);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user