mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
separate column templates from doc list (#700)
* use standard date columns * use standard file size column * name column component * library name template * library status column * enable tests * trashcan name column template
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
*/
|
||||
|
||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import {
|
||||
@@ -36,10 +35,8 @@ import {
|
||||
AppConfigPipe
|
||||
} from '@alfresco/adf-core';
|
||||
import { DocumentListComponent } from '@alfresco/adf-content-services';
|
||||
import { ShareDataTableAdapter } from '@alfresco/adf-content-services';
|
||||
import { LibrariesComponent } from './libraries.component';
|
||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
import { ContentApiService } from '../../services/content-api.service';
|
||||
import { ExperimentalDirective } from '../../directives/experimental.directive';
|
||||
import { EffectsModule } from '@ngrx/effects';
|
||||
import { LibraryEffects } from 'src/app/store/effects';
|
||||
@@ -47,11 +44,9 @@ import { LibraryEffects } from 'src/app/store/effects';
|
||||
describe('LibrariesComponent', () => {
|
||||
let fixture: ComponentFixture<LibrariesComponent>;
|
||||
let component: LibrariesComponent;
|
||||
let contentApi: ContentApiService;
|
||||
let alfrescoApi: AlfrescoApiService;
|
||||
let router: Router;
|
||||
let page;
|
||||
let node;
|
||||
|
||||
beforeEach(() => {
|
||||
page = {
|
||||
@@ -60,13 +55,6 @@ describe('LibrariesComponent', () => {
|
||||
pagination: { data: 'data' }
|
||||
}
|
||||
};
|
||||
|
||||
node = <any>{
|
||||
id: 'nodeId',
|
||||
path: {
|
||||
elements: []
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -98,100 +86,14 @@ describe('LibrariesComponent', () => {
|
||||
spyOn(alfrescoApi.peopleApi, 'getSiteMembership').and.returnValue(
|
||||
Promise.resolve({})
|
||||
);
|
||||
|
||||
contentApi = TestBed.get(ContentApiService);
|
||||
});
|
||||
|
||||
describe('makeLibraryTooltip()', () => {
|
||||
it('maps tooltip to description', () => {
|
||||
node.description = 'description';
|
||||
const tooltip = component.makeLibraryTooltip(node);
|
||||
|
||||
expect(tooltip).toBe(node.description);
|
||||
});
|
||||
|
||||
it('maps tooltip to description', () => {
|
||||
node.title = 'title';
|
||||
const tooltip = component.makeLibraryTooltip(node);
|
||||
|
||||
expect(tooltip).toBe(node.title);
|
||||
});
|
||||
|
||||
it('sets tooltip to empty string', () => {
|
||||
const tooltip = component.makeLibraryTooltip(node);
|
||||
|
||||
expect(tooltip).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('makeLibraryTitle()', () => {
|
||||
it('sets title with id when duplicate nodes title exists in list', () => {
|
||||
node.title = 'title';
|
||||
|
||||
const data = new ShareDataTableAdapter(null, null);
|
||||
data.setRows([
|
||||
<any>{ node: { entry: { id: 'some-id', title: 'title' } } }
|
||||
]);
|
||||
|
||||
component.documentList.data = data;
|
||||
|
||||
const title = component.makeLibraryTitle(node);
|
||||
expect(title).toContain('nodeId');
|
||||
});
|
||||
|
||||
it('sets title when no duplicate nodes title exists in list', () => {
|
||||
node.title = 'title';
|
||||
|
||||
const data = new ShareDataTableAdapter(null, null);
|
||||
data.setRows([
|
||||
<any>{ node: { entry: { id: 'some-id', title: 'title-some-id' } } }
|
||||
]);
|
||||
|
||||
component.documentList.data = data;
|
||||
const title = component.makeLibraryTitle(node);
|
||||
|
||||
expect(title).toBe('title');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Node navigation', () => {
|
||||
it('does not navigate when id is not passed', () => {
|
||||
spyOn(router, 'navigate').and.stub();
|
||||
component.navigate(null);
|
||||
component.navigateTo(null);
|
||||
|
||||
expect(router.navigate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('navigates to node id', () => {
|
||||
const document = { id: 'documentId' };
|
||||
spyOn(router, 'navigate').and.stub();
|
||||
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: document }));
|
||||
|
||||
component.navigate(node.id);
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(['libraries', 'documentId']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('navigateTo', () => {
|
||||
it('navigates into library folder', () => {
|
||||
spyOn(component, 'navigate');
|
||||
|
||||
const site: any = {
|
||||
entry: { guid: 'node-guid' }
|
||||
};
|
||||
|
||||
component.navigateTo(site);
|
||||
|
||||
expect(component.navigate).toHaveBeenCalledWith('node-guid');
|
||||
});
|
||||
|
||||
it(' does not navigate when library is not provided', () => {
|
||||
spyOn(component, 'navigate');
|
||||
|
||||
component.navigateTo(null);
|
||||
|
||||
expect(component.navigate).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user