[AAE-1883] document list preset unit tests (#5519)

* document list preset unit tests

* remove useless tests

* remove useless tests

* remove even more garbage

* remove junk
This commit is contained in:
Denys Vuika 2020-02-28 13:26:01 +00:00 committed by GitHub
parent b5d443f2a8
commit a9b49a1eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 127 additions and 664 deletions

View File

@ -1,36 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { HomeComponent } from './home.component';
import { CoreModule } from '@alfresco/adf-core';
describe('HomeComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreModule.forRoot()],
declarations: [HomeComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
});
it ('should work', () => {
const fixture = TestBed.createComponent(HomeComponent);
expect(fixture.componentInstance instanceof HomeComponent).toBe(true, 'should create HomeComponent');
});
});

View File

@ -1,69 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { DataColumn, setupTestBed, LogService } from '@alfresco/adf-core';
import { DocumentListComponent } from './../document-list.component';
import { ContentColumnListComponent } from './content-column-list.component';
import { ContentTestingModule } from '../../../testing/content.testing.module';
describe('ContentColumnList', () => {
let documentList: DocumentListComponent;
let columnList: ContentColumnListComponent;
let logService: LogService;
setupTestBed({
imports: [ContentTestingModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
beforeEach(() => {
documentList = (TestBed.createComponent(DocumentListComponent).componentInstance as DocumentListComponent);
logService = TestBed.get(LogService);
columnList = new ContentColumnListComponent(documentList, logService);
documentList.ngOnInit();
});
it('should register column within parent document list', () => {
const columns = documentList.data.getColumns();
expect(columns.length).toBe(0);
const column = <DataColumn> {};
const result = columnList.registerColumn(column);
expect(result).toBeTruthy();
expect(columns.length).toBe(1);
expect(columns[0]).toBe(column);
});
it('should require document list instance to register action', () => {
columnList = new ContentColumnListComponent(null, logService);
const col = <DataColumn> {};
expect(columnList.registerColumn(col)).toBeFalsy();
});
it('should require action instance to register', () => {
spyOn(documentList.actions, 'push').and.callThrough();
const result = columnList.registerColumn(null);
expect(result).toBeFalsy();
expect(documentList.actions.push).not.toHaveBeenCalled();
});
});

View File

@ -1,47 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* tslint:disable:component-selector */
import { DataColumn, LogService } from '@alfresco/adf-core';
import { Component } from '@angular/core';
import { DocumentListComponent } from './../document-list.component';
@Component({
selector: 'content-columns',
template: ''
})
export class ContentColumnListComponent {
constructor(private documentList: DocumentListComponent, private logService: LogService ) {
this.logService.log('ContentColumnListComponent is deprecated starting with 1.7.0 and may be removed in future versions. Use DataColumnListComponent instead.');
}
/**
* Registers column model within the parent document list component.
* @param column Column definition model to register.
*/
registerColumn(column: DataColumn): boolean {
if (this.documentList && column) {
const columns = this.documentList.data.getColumns();
columns.push(column);
return true;
}
return false;
}
}

View File

@ -1,81 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { LogService, setupTestBed } from '@alfresco/adf-core';
import { DocumentListComponent } from './../document-list.component';
import { ContentColumnListComponent } from './content-column-list.component';
import { ContentColumnComponent } from './content-column.component';
import { ContentTestingModule } from '../../../testing/content.testing.module';
describe('ContentColumn', () => {
let documentList: DocumentListComponent;
let columnList: ContentColumnListComponent;
let logService: LogService;
setupTestBed({
imports: [ContentTestingModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
beforeEach(() => {
documentList = (TestBed.createComponent(DocumentListComponent).componentInstance as DocumentListComponent);
logService = TestBed.get(LogService);
columnList = new ContentColumnListComponent(documentList, logService);
documentList.ngOnInit();
});
it('should register model within parent column list', () => {
spyOn(columnList, 'registerColumn').and.callThrough();
const column = new ContentColumnComponent(columnList, logService);
column.ngAfterContentInit();
expect(columnList.registerColumn).toHaveBeenCalled();
const columns = documentList.data.getColumns();
expect(columns.length).toBe(1);
expect(columns[0]).toBe(column);
});
it('should setup screen reader title for thumbnail column', () => {
const column = new ContentColumnComponent(columnList, logService);
column.key = '$thumbnail';
column.ngOnInit();
expect(column.srTitle).toBe('Thumbnail');
});
it('should register on init', () => {
const column = new ContentColumnComponent(columnList, logService);
spyOn(column, 'register').and.callThrough();
column.ngAfterContentInit();
expect(column.register).toHaveBeenCalled();
});
it('should require action list to register action with', () => {
let column = new ContentColumnComponent(columnList, logService);
expect(column.register()).toBeTruthy();
column = new ContentColumnComponent(null, logService);
expect(column.register()).toBeFalsy();
});
});

View File

@ -1,77 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* tslint:disable:component-selector no-input-rename */
import { DataColumn, DataColumnType, LogService } from '@alfresco/adf-core';
import { AfterContentInit, Component, ContentChild, Input, OnInit, TemplateRef } from '@angular/core';
import { ContentColumnListComponent } from './content-column-list.component';
@Component({
selector: 'content-column',
template: ''
})
export class ContentColumnComponent implements OnInit, AfterContentInit, DataColumn {
@Input()
key: string;
@Input()
type: DataColumnType = 'text';
@Input()
format: string;
@Input()
sortable: boolean = false;
@Input()
title: string = '';
@ContentChild(TemplateRef)
template: any;
/**
* Title to be used for screen readers.
*/
@Input('sr-title')
srTitle: string;
@Input('class')
cssClass: string;
constructor(private list: ContentColumnListComponent, private logService: LogService) {
this.logService.log('ContentColumnComponent is deprecated starting with 1.7.0 and may be removed in future versions. Use DataColumnComponent instead.');
}
ngOnInit() {
if (!this.srTitle && this.key === '$thumbnail') {
this.srTitle = 'Thumbnail';
}
}
ngAfterContentInit() {
this.register();
}
register(): boolean {
if (this.list) {
return this.list.registerColumn(this);
}
return false;
}
}

View File

@ -104,6 +104,123 @@ describe('DocumentList', () => {
fixture.destroy(); fixture.destroy();
}); });
describe('presets', () => {
const validatePreset = (keys: string[]) => {
const columns = documentList.data.getColumns();
expect(columns.length).toBe(keys.length);
keys.forEach((key, index) => {
expect(columns[index].key).toBe(key);
});
};
it('should load -trashcan- preset', async () => {
documentList.currentFolderId = '-trashcan-';
fixture.detectChanges();
await fixture.whenStable();
validatePreset([
'$thumbnail',
'name',
'path',
'content.sizeInBytes',
'archivedAt',
'archivedByUser.displayName'
]);
});
it('should load -sites- preset', async () => {
documentList.currentFolderId = '-sites-';
fixture.detectChanges();
await fixture.whenStable();
validatePreset([
'$thumbnail',
'title',
'visibility'
]);
});
it('shuld load -mysites- preset', async () => {
documentList.currentFolderId = '-mysites-';
fixture.detectChanges();
await fixture.whenStable();
validatePreset([
'$thumbnail',
'title',
'visibility'
]);
});
it('should load -favorites- preset', async () => {
documentList.currentFolderId = '-favorites-';
fixture.detectChanges();
await fixture.whenStable();
validatePreset([
'$thumbnail',
'name',
'path',
'content.sizeInBytes',
'modifiedAt',
'modifiedByUser.displayName'
]);
});
it('should load -recent- preset', async () => {
documentList.currentFolderId = '-recent-';
fixture.detectChanges();
await fixture.whenStable();
validatePreset([
'$thumbnail',
'name',
'path',
'content.sizeInBytes',
'modifiedAt'
]);
});
it('should load -sharedlinks- preset', async () => {
documentList.currentFolderId = '-sharedlinks-';
fixture.detectChanges();
await fixture.whenStable();
validatePreset([
'$thumbnail',
'name',
'path',
'content.sizeInBytes',
'modifiedAt',
'modifiedByUser.displayName',
'sharedByUser.displayName'
]);
});
it('should load default preset', async () => {
documentList.currentFolderId = 'f5dacdb9-6d07-4fe9-9f2a-dedc21bae603';
fixture.detectChanges();
await fixture.whenStable();
validatePreset([
'$thumbnail',
'name',
'content.sizeInBytes',
'modifiedAt',
'modifiedByUser.displayName'
]);
});
});
it('should update schema if columns change', fakeAsync(() => { it('should update schema if columns change', fakeAsync(() => {
documentList.columnList = new DataColumnListComponent(); documentList.columnList = new DataColumnListComponent();
documentList.columnList.columns = new QueryList<DataColumnComponent>(); documentList.columnList.columns = new QueryList<DataColumnComponent>();

View File

@ -25,8 +25,6 @@ import { UploadModule } from '../upload/upload.module';
import { ContentActionListComponent } from './components/content-action/content-action-list.component'; import { ContentActionListComponent } from './components/content-action/content-action-list.component';
import { ContentActionComponent } from './components/content-action/content-action.component'; import { ContentActionComponent } from './components/content-action/content-action.component';
import { ContentColumnListComponent } from './components/content-column/content-column-list.component';
import { ContentColumnComponent } from './components/content-column/content-column.component';
import { DocumentListComponent } from './components/document-list.component'; import { DocumentListComponent } from './components/document-list.component';
import { TrashcanNameColumnComponent } from './components/trashcan-name-column/trashcan-name-column.component'; import { TrashcanNameColumnComponent } from './components/trashcan-name-column/trashcan-name-column.component';
@ -46,25 +44,21 @@ import { NameColumnComponent } from './components/name-column/name-column.compon
], ],
declarations: [ declarations: [
DocumentListComponent, DocumentListComponent,
ContentColumnComponent,
TrashcanNameColumnComponent, TrashcanNameColumnComponent,
LibraryStatusColumnComponent, LibraryStatusColumnComponent,
LibraryRoleColumnComponent, LibraryRoleColumnComponent,
LibraryNameColumnComponent, LibraryNameColumnComponent,
NameColumnComponent, NameColumnComponent,
ContentColumnListComponent,
ContentActionComponent, ContentActionComponent,
ContentActionListComponent ContentActionListComponent
], ],
exports: [ exports: [
DocumentListComponent, DocumentListComponent,
ContentColumnComponent,
TrashcanNameColumnComponent, TrashcanNameColumnComponent,
LibraryStatusColumnComponent, LibraryStatusColumnComponent,
LibraryRoleColumnComponent, LibraryRoleColumnComponent,
LibraryNameColumnComponent, LibraryNameColumnComponent,
NameColumnComponent, NameColumnComponent,
ContentColumnListComponent,
ContentActionComponent, ContentActionComponent,
ContentActionListComponent ContentActionListComponent
], ],

View File

@ -17,8 +17,6 @@
export * from './components/document-list.component'; export * from './components/document-list.component';
export * from './components/node.event'; export * from './components/node.event';
export * from './components/content-column/content-column.component';
export * from './components/content-column/content-column-list.component';
export * from './components/content-action/content-action.component'; export * from './components/content-action/content-action.component';
export * from './components/content-action/content-action-list.component'; export * from './components/content-action/content-action-list.component';
export * from './components/library-name-column/library-name-column.component'; export * from './components/library-name-column/library-name-column.component';

View File

@ -60,10 +60,6 @@ describe('NodeActionsService', () => {
contentDialogService = TestBed.get(ContentNodeDialogService); contentDialogService = TestBed.get(ContentNodeDialogService);
}); });
it('should be able to create the service', () => {
expect(service).not.toBeNull();
});
it('should be able to copy content', async(() => { it('should be able to copy content', async(() => {
spyOn(documentListService, 'copyNode').and.returnValue(of('FAKE-OK')); spyOn(documentListService, 'copyNode').and.returnValue(of('FAKE-OK'));
spyOn(contentDialogService, 'openCopyMoveDialog').and.returnValue(of([fakeNode])); spyOn(contentDialogService, 'openCopyMoveDialog').and.returnValue(of([fakeNode]));

View File

@ -54,10 +54,6 @@ describe('NodePermissionDialogService', () => {
}); });
}); });
it('should be able to create the service', () => {
expect(service).not.toBeNull();
});
describe('when node has permission to update permissions', () => { describe('when node has permission to update permissions', () => {
let fakePermissionNode = new Node({}); let fakePermissionNode = new Node({});

View File

@ -54,10 +54,6 @@ describe('CardViewArrayItemComponent', () => {
component.property = new CardViewArrayItemModel(mockDefaultProps); component.property = new CardViewArrayItemModel(mockDefaultProps);
}); });
it('should create CardViewArrayItemComponent', () => {
expect(component instanceof CardViewArrayItemComponent).toBeTruthy();
});
describe('Rendering', () => { describe('Rendering', () => {
it('should render the label', () => { it('should render the label', () => {
fixture.detectChanges(); fixture.detectChanges();

View File

@ -1,34 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TestBed } from '@angular/core/testing';
import { DataColumnListComponent } from './data-column-list.component';
import { setupTestBed } from '../testing/setup-test-bed';
import { CoreTestingModule } from '../testing/core.testing.module';
describe('DataColumnListComponent', () => {
setupTestBed({
imports: [CoreTestingModule]
});
it('should create the component', () => {
const fixture = TestBed.createComponent(DataColumnListComponent);
const component = fixture.debugElement.componentInstance;
expect(component).toBeTruthy();
});
});

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
import { TestBed } from '@angular/core/testing';
import { DataColumnComponent } from './data-column.component'; import { DataColumnComponent } from './data-column.component';
import { setupTestBed } from '../testing/setup-test-bed'; import { setupTestBed } from '../testing/setup-test-bed';
import { CoreTestingModule } from '../testing/core.testing.module'; import { CoreTestingModule } from '../testing/core.testing.module';
@ -26,12 +25,6 @@ describe('DataColumnListComponent', () => {
imports: [CoreTestingModule] imports: [CoreTestingModule]
}); });
it('should create the component', () => {
const fixture = TestBed.createComponent(DataColumnComponent);
const component = fixture.debugElement.componentInstance;
expect(component).toBeTruthy();
});
it('should setup screen reader title for thumbnails', () => { it('should setup screen reader title for thumbnails', () => {
const component = new DataColumnComponent(); const component = new DataColumnComponent();
component.key = '$thumbnail'; component.key = '$thumbnail';

View File

@ -56,10 +56,6 @@ describe('DateEditorComponent', () => {
component.column = column; component.column = column;
}); });
it('should create instance of DateEditorComponent', () => {
expect(fixture.componentInstance instanceof DateEditorComponent).toBe(true, 'should create DateEditorComponent');
});
describe('using Date Piker', () => { describe('using Date Piker', () => {
it('should update row value on change', () => { it('should update row value on change', () => {
const input = <MatDatepickerInputEvent<any>> {value: '14-03-2016' }; const input = <MatDatepickerInputEvent<any>> {value: '14-03-2016' };

View File

@ -55,10 +55,6 @@ describe('DateTimeEditorComponent', () => {
component.column = column; component.column = column;
}); });
it('should create instance of DateTimeEditorComponent', () => {
expect(fixture.componentInstance instanceof DateTimeEditorComponent).toBe(true, 'should create DateTimeEditorComponent');
});
it('should update fow value on change', () => { it('should update fow value on change', () => {
component.ngOnInit(); component.ngOnInit();
const newDate = moment('22-6-2018 04:20 AM', 'D-M-YYYY hh:mm A'); const newDate = moment('22-6-2018 04:20 AM', 'D-M-YYYY hh:mm A');

View File

@ -48,10 +48,6 @@ describe('InfoDrawerComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
}); });
it('should create instance of InfoDrawerComponent', () => {
expect(fixture.componentInstance instanceof InfoDrawerComponent).toBe(true, 'should create InfoDrawerComponent');
});
it('should define InfoDrawerTabLayout', () => { it('should define InfoDrawerTabLayout', () => {
const infoDrawerTabLayout = element.querySelector('adf-info-drawer-layout'); const infoDrawerTabLayout = element.querySelector('adf-info-drawer-layout');
expect(infoDrawerTabLayout).toBeDefined(); expect(infoDrawerTabLayout).toBeDefined();

View File

@ -43,10 +43,6 @@ describe('HeaderLayoutComponent', () => {
fixture.destroy(); fixture.destroy();
}); });
it('should create instance of HeaderLayoutComponent', () => {
expect(fixture.componentInstance instanceof HeaderLayoutComponent).toBe(true, 'should create HeaderLayoutComponent');
});
it('title element should been displayed', () => { it('title element should been displayed', () => {
const titleElement = fixture.debugElement.query(By.css('.adf-app-title')); const titleElement = fixture.debugElement.query(By.css('.adf-app-title'));
expect(titleElement === null).toBeFalsy(); expect(titleElement === null).toBeFalsy();

View File

@ -44,11 +44,6 @@ describe('LoginDialogService', () => {
}); });
}); });
it('should be able to create the service', () => {
expect(service).not.toBeNull();
expect(service).toBeDefined();
});
it('should be able to open the dialog when node has permission', () => { it('should be able to open the dialog when node has permission', () => {
service.openLogin('fake-title', 'fake-action'); service.openLogin('fake-title', 'fake-action');
expect(spyOnDialogOpen).toHaveBeenCalled(); expect(spyOnDialogOpen).toHaveBeenCalled();

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { setupTestBed } from '@alfresco/adf-core'; import { setupTestBed } from '@alfresco/adf-core';
import { fakeApplicationInstance } from '../mock/app-model.mock'; import { fakeApplicationInstance } from '../mock/app-model.mock';
@ -39,10 +39,6 @@ describe('AppDetailsCloudComponent', () => {
component.applicationInstance = fakeApplicationInstance[0]; component.applicationInstance = fakeApplicationInstance[0];
}); });
it('should create AppDetailsCloudComponent ', async(() => {
expect(component instanceof AppDetailsCloudComponent).toBe(true);
}));
it('should display application name', () => { it('should display application name', () => {
fixture.detectChanges(); fixture.detectChanges();
const appName = fixture.nativeElement.querySelector('.adf-app-listgrid-item-card-title'); const appName = fixture.nativeElement.querySelector('.adf-app-listgrid-item-card-title');

View File

@ -58,10 +58,6 @@ describe('AppListCloudComponent', () => {
getAppsSpy = spyOn(appsProcessCloudService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); getAppsSpy = spyOn(appsProcessCloudService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance));
}); });
it('should create AppListCloudComponent ', async(() => {
expect(component instanceof AppListCloudComponent).toBe(true);
}));
it('should define layoutType with the default value', () => { it('should define layoutType with the default value', () => {
component.layoutType = ''; component.layoutType = '';
fixture.detectChanges(); fixture.detectChanges();

View File

@ -872,10 +872,6 @@ describe('FormCloudWithCustomOutComesComponent', () => {
fixture.destroy(); fixture.destroy();
}); });
it('should create instance of FormCloudWithCustomOutComesComponent', () => {
expect(component instanceof FormCloudWithCustomOutComesComponent).toBe(true, 'should create FormCloudWithCustomOutComesComponent');
});
it('should be able to inject custom outcomes and click on custom outcomes', () => { it('should be able to inject custom outcomes and click on custom outcomes', () => {
fixture.detectChanges(); fixture.detectChanges();
const cancelSpy = spyOn(component, 'onButtonClick').and.callThrough(); const cancelSpy = spyOn(component, 'onButtonClick').and.callThrough();

View File

@ -87,10 +87,6 @@ describe('EditProcessFilterCloudComponent', () => {
fixture.destroy(); fixture.destroy();
}); });
it('should create EditProcessFilterCloudComponent', () => {
expect(component instanceof EditProcessFilterCloudComponent).toBeTruthy();
});
it('should fetch process instance filter by id', async(() => { it('should fetch process instance filter by id', async(() => {
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ 'id': processFilterIdChange });

View File

@ -49,10 +49,6 @@ describe('ProcessFilterDialogCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should create ProcessFilterDialogCloudComponent', () => {
expect(component instanceof ProcessFilterDialogCloudComponent).toBeTruthy();
});
it('should get data from MAT_DIALOG_DATA as an input to the dialog', () => { it('should get data from MAT_DIALOG_DATA as an input to the dialog', () => {
fixture.detectChanges(); fixture.detectChanges();
const mockData = component.data; const mockData = component.data;

View File

@ -28,7 +28,6 @@ import { ProcessFiltersCloudModule } from '../process-filters-cloud.module';
import { FilterParamsModel } from '../../../task/task-filters/models/filter-cloud.model'; import { FilterParamsModel } from '../../../task/task-filters/models/filter-cloud.model';
import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service'; import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service'; import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service';
import { UserPreferenceCloudService } from '../../../services/user-preference-cloud.service';
describe('ProcessFiltersCloudComponent', () => { describe('ProcessFiltersCloudComponent', () => {
@ -91,14 +90,6 @@ describe('ProcessFiltersCloudComponent', () => {
processFilterService = TestBed.get(ProcessFilterCloudService); processFilterService = TestBed.get(ProcessFilterCloudService);
}); });
it('should create ProcessFiltersCloudComponent instance', () => {
expect(component instanceof ProcessFiltersCloudComponent).toBeDefined();
});
it('should be able to use LocalPreferenceCloudService', () => {
expect(processFilterService.preferenceService instanceof LocalPreferenceCloudService).toBeTruthy();
});
it('should attach specific icon for each filter if hasIcon is true', async(() => { it('should attach specific icon for each filter if hasIcon is true', async(() => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(fakeGlobalFilterObservable); spyOn(processFilterService, 'getProcessFilters').and.returnValue(fakeGlobalFilterObservable);
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
@ -362,32 +353,3 @@ describe('ProcessFiltersCloudComponent', () => {
expect(component.getCurrentFilter()).toBe(filter); expect(component.getCurrentFilter()).toBe(filter);
}); });
}); });
describe('Set UserPreferenceService', () => {
let processFilterService: ProcessFilterCloudService;
let component: ProcessFiltersCloudComponent;
let fixture: ComponentFixture<ProcessFiltersCloudComponent>;
setupTestBed({
imports: [ProcessServiceCloudTestingModule, ProcessFiltersCloudModule],
providers: [
ProcessFilterCloudService,
{ provide: PROCESS_FILTERS_SERVICE_TOKEN, useClass: UserPreferenceCloudService }
]
});
beforeEach(() => {
fixture = TestBed.createComponent(ProcessFiltersCloudComponent);
component = fixture.componentInstance;
processFilterService = TestBed.get(ProcessFilterCloudService);
});
it('should create ProcessFiltersCloudComponent instance', () => {
expect(component instanceof ProcessFiltersCloudComponent).toBeDefined();
});
it('should able to inject UserPreferenceCloudService when you override with user preferece service', () => {
expect(processFilterService.preferenceService instanceof UserPreferenceCloudService).toBeTruthy();
});
});

View File

@ -26,15 +26,11 @@ import {
fakeProcessCloudFilterWithDifferentEntries, fakeProcessCloudFilterWithDifferentEntries,
fakeProcessFilter fakeProcessFilter
} from '../mock/process-filters.cloud.mock'; } from '../mock/process-filters.cloud.mock';
import { PreferenceCloudServiceInterface } from '../../../services/preference-cloud.interface';
import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service'; import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service'; import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service';
import { UserPreferenceCloudService } from '../../../services/user-preference-cloud.service';
describe('ProcessFilterCloudService', () => { describe('ProcessFilterCloudService', () => {
let service: ProcessFilterCloudService; let service: ProcessFilterCloudService;
let preferenceCloudService: PreferenceCloudServiceInterface;
let identityUserService: IdentityUserService;
let getPreferencesSpy: jasmine.Spy; let getPreferencesSpy: jasmine.Spy;
let getPreferenceByKeySpy: jasmine.Spy; let getPreferenceByKeySpy: jasmine.Spy;
let updatePreferenceSpy: jasmine.Spy; let updatePreferenceSpy: jasmine.Spy;
@ -57,8 +53,10 @@ describe('ProcessFilterCloudService', () => {
beforeEach(async(() => { beforeEach(async(() => {
service = TestBed.get(ProcessFilterCloudService); service = TestBed.get(ProcessFilterCloudService);
preferenceCloudService = service.preferenceService;
identityUserService = TestBed.get(IdentityUserService); const preferenceCloudService = service.preferenceService;
const identityUserService = TestBed.get(IdentityUserService);
createPreferenceSpy = spyOn(preferenceCloudService, 'createPreference').and.returnValue(of(fakeProcessCloudFilters)); createPreferenceSpy = spyOn(preferenceCloudService, 'createPreference').and.returnValue(of(fakeProcessCloudFilters));
updatePreferenceSpy = spyOn(preferenceCloudService, 'updatePreference').and.returnValue(of(fakeProcessCloudFilters)); updatePreferenceSpy = spyOn(preferenceCloudService, 'updatePreference').and.returnValue(of(fakeProcessCloudFilters));
getPreferenceByKeySpy = spyOn(preferenceCloudService, 'getPreferenceByKey').and.returnValue(of(fakeProcessCloudFilters)); getPreferenceByKeySpy = spyOn(preferenceCloudService, 'getPreferenceByKey').and.returnValue(of(fakeProcessCloudFilters));
@ -66,14 +64,6 @@ describe('ProcessFilterCloudService', () => {
getCurrentUserInfoSpy = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock); getCurrentUserInfoSpy = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
})); }));
it('should create ProcessFilterCloudService instance', () => {
expect(service).toBeDefined();
});
it('should be able to use LocalPreferenceCloudService', () => {
expect(preferenceCloudService instanceof LocalPreferenceCloudService).toBeTruthy();
});
it('should create processfilter key by using appName and the username', (done) => { it('should create processfilter key by using appName and the username', (done) => {
service.getProcessFilters('mock-appName').subscribe((res: any) => { service.getProcessFilters('mock-appName').subscribe((res: any) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
@ -220,38 +210,3 @@ describe('ProcessFilterCloudService', () => {
expect(updatePreferenceSpy).toHaveBeenCalled(); expect(updatePreferenceSpy).toHaveBeenCalled();
}); });
}); });
describe('Inject [UserPreferenceCloudService] into the ProcessFilterCloudService', () => {
let service: ProcessFilterCloudService;
let preferenceCloudService: PreferenceCloudServiceInterface;
let identityUserService: IdentityUserService;
const identityUserMock = { username: 'mock-username', firstName: 'fake-identity-first-name', lastName: 'fake-identity-last-name', email: 'fakeIdentity@email.com' };
setupTestBed({
imports: [
CoreModule.forRoot()
],
providers: [
ProcessFilterCloudService,
IdentityUserService,
UserPreferenceCloudService,
{ provide: PROCESS_FILTERS_SERVICE_TOKEN, useClass: UserPreferenceCloudService }
]
});
beforeEach(async(() => {
service = TestBed.get(ProcessFilterCloudService);
preferenceCloudService = service.preferenceService;
identityUserService = TestBed.get(IdentityUserService);
spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
}));
it('should create ProcessFilterCloudService instance', () => {
expect(service).toBeDefined();
});
it('should be able to inject UserPreferenceCloudService when you override with user preferece service', () => {
expect(preferenceCloudService instanceof UserPreferenceCloudService).toBeTruthy();
});
});

View File

@ -224,10 +224,6 @@ describe('ProcessListCloudComponent', () => {
fixtureCustom.destroy(); fixtureCustom.destroy();
}); });
it('should create instance of CustomTaskListComponent', () => {
expect(componentCustom instanceof CustomTaskListComponent).toBe(true, 'should create CustomTaskListComponent');
});
it('should fetch custom schemaColumn from html', () => { it('should fetch custom schemaColumn from html', () => {
fixture.detectChanges(); fixture.detectChanges();
expect(componentCustom.processListCloud.columnList).toBeDefined(); expect(componentCustom.processListCloud.columnList).toBeDefined();

View File

@ -74,10 +74,6 @@ describe('StartProcessCloudComponent', () => {
TestBed.resetTestingModule(); TestBed.resetTestingModule();
}); });
it('should create instance of StartProcessInstanceComponent', () => {
expect(fixture.componentInstance instanceof StartProcessCloudComponent).toBe(true, 'should create StartProcessInstanceComponent');
});
describe('start a process without start form', () => { describe('start a process without start form', () => {
it('should be able to start a process with a valid process name and process definition', async(() => { it('should be able to start a process with a valid process name and process definition', async(() => {

View File

@ -62,10 +62,6 @@ describe('PreferenceService', () => {
getInstanceSpy = spyOn(alfrescoApiMock, 'getInstance').and.returnValue(apiMock(mockPreferences)); getInstanceSpy = spyOn(alfrescoApiMock, 'getInstance').and.returnValue(apiMock(mockPreferences));
})); }));
it('should create UserPreferenceCloudService instance', () => {
expect(service).toBeTruthy();
});
it('should return the preferences', (done) => { it('should return the preferences', (done) => {
service.getPreferences('mock-app-name').subscribe((res: any) => { service.getPreferences('mock-app-name').subscribe((res: any) => {
expect(res).toBeDefined(); expect(res).toBeDefined();

View File

@ -84,10 +84,6 @@ describe('StartTaskCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
})); }));
it('should create instance of StartTaskCloudComponent', () => {
expect(component instanceof StartTaskCloudComponent).toBe(true, 'should create StartTaskCloudComponent');
});
describe('create task', () => { describe('create task', () => {
it('should create new task when start button is clicked', async(() => { it('should create new task when start button is clicked', async(() => {

View File

@ -1,30 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TaskCloudModule } from './task-cloud.module';
describe('TaskCloudModule', () => {
let taskCloudModule: TaskCloudModule;
beforeEach(() => {
taskCloudModule = new TaskCloudModule();
});
it('should create an instance', () => {
expect(taskCloudModule).toBeTruthy();
});
});

View File

@ -48,10 +48,6 @@ describe('TaskFilterDialogCloudComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
}); });
it('should create TaskFilterDialogCloudComponent', () => {
expect(component instanceof TaskFilterDialogCloudComponent).toBeTruthy();
});
it('should get data from MAT_DIALOG_DATA as an input to the dialog', () => { it('should get data from MAT_DIALOG_DATA as an input to the dialog', () => {
fixture.detectChanges(); fixture.detectChanges();
const mockData = component.data; const mockData = component.data;

View File

@ -28,7 +28,6 @@ import { By } from '@angular/platform-browser';
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module'; import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
import { TaskFiltersCloudModule } from '../task-filters-cloud.module'; import { TaskFiltersCloudModule } from '../task-filters-cloud.module';
import { fakeGlobalFilter } from '../mock/task-filters-cloud.mock'; import { fakeGlobalFilter } from '../mock/task-filters-cloud.mock';
import { UserPreferenceCloudService } from '../../../services/user-preference-cloud.service';
describe('TaskFiltersCloudComponent', () => { describe('TaskFiltersCloudComponent', () => {
@ -68,14 +67,6 @@ describe('TaskFiltersCloudComponent', () => {
taskFilterService = TestBed.get(TaskFilterCloudService); taskFilterService = TestBed.get(TaskFilterCloudService);
}); });
it('should create TaskFiltersCloudComponent instance', () => {
expect(component instanceof TaskFiltersCloudComponent).toBeDefined();
});
it('should be able to use LocalPreferenceCloudService', () => {
expect(taskFilterService.preferenceService instanceof LocalPreferenceCloudService).toBeTruthy();
});
it('should attach specific icon for each filter if hasIcon is true', async(() => { it('should attach specific icon for each filter if hasIcon is true', async(() => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable); spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
@ -342,33 +333,3 @@ describe('TaskFiltersCloudComponent', () => {
expect(component.getCurrentFilter()).toBe(fakeGlobalFilter[0]); expect(component.getCurrentFilter()).toBe(fakeGlobalFilter[0]);
}); });
}); });
describe('Set UserPreferenceService', () => {
let component: TaskFiltersCloudComponent;
let taskFilterService: TaskFilterCloudService;
let fixture: ComponentFixture<TaskFiltersCloudComponent>;
setupTestBed({
imports: [ProcessServiceCloudTestingModule, TaskFiltersCloudModule],
providers: [
TaskFilterCloudService,
{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: UserPreferenceCloudService }
]
});
beforeEach(() => {
fixture = TestBed.createComponent(TaskFiltersCloudComponent);
component = fixture.componentInstance;
taskFilterService = TestBed.get(TaskFilterCloudService);
});
it('should create TaskFiltersCloudComponent instance', () => {
expect(component instanceof TaskFiltersCloudComponent).toBeDefined();
});
it('should be able to inject UserPreferenceCloudService when you override with user preferece service', () => {
expect(taskFilterService.preferenceService instanceof UserPreferenceCloudService).toBeTruthy();
});
});

View File

@ -44,8 +44,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('TaskFilterCloudService', () => { describe('TaskFilterCloudService', () => {
let service: TaskFilterCloudService; let service: TaskFilterCloudService;
let preferenceCloudService: PreferenceCloudServiceInterface;
let identityUserService: IdentityUserService;
let getPreferencesSpy: jasmine.Spy; let getPreferencesSpy: jasmine.Spy;
let getPreferenceByKeySpy: jasmine.Spy; let getPreferenceByKeySpy: jasmine.Spy;
let createPreferenceSpy: jasmine.Spy; let createPreferenceSpy: jasmine.Spy;
@ -72,17 +71,15 @@ describe('TaskFilterCloudService', () => {
beforeEach(() => { beforeEach(() => {
service = TestBed.get(TaskFilterCloudService); service = TestBed.get(TaskFilterCloudService);
preferenceCloudService = service.preferenceService;
identityUserService = TestBed.get(IdentityUserService); const preferenceCloudService = service.preferenceService;
createPreferenceSpy = spyOn(preferenceCloudService, 'createPreference').and.returnValue(of(fakeTaskCloudFilters)); createPreferenceSpy = spyOn(preferenceCloudService, 'createPreference').and.returnValue(of(fakeTaskCloudFilters));
updatePreferenceSpy = spyOn(preferenceCloudService, 'updatePreference').and.returnValue(of(fakeTaskCloudFilters)); updatePreferenceSpy = spyOn(preferenceCloudService, 'updatePreference').and.returnValue(of(fakeTaskCloudFilters));
getPreferencesSpy = spyOn(preferenceCloudService, 'getPreferences').and.returnValue(of(fakeTaskCloudPreferenceList)); getPreferencesSpy = spyOn(preferenceCloudService, 'getPreferences').and.returnValue(of(fakeTaskCloudPreferenceList));
getPreferenceByKeySpy = spyOn(preferenceCloudService, 'getPreferenceByKey').and.returnValue(of(fakeTaskCloudFilters)); getPreferenceByKeySpy = spyOn(preferenceCloudService, 'getPreferenceByKey').and.returnValue(of(fakeTaskCloudFilters));
getCurrentUserInfoSpy = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
});
it('should be able to use UserPreferenceCloudService', () => { const identityUserService = TestBed.get(IdentityUserService);
expect(preferenceCloudService instanceof UserPreferenceCloudService).toBeTruthy(); getCurrentUserInfoSpy = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
}); });
it('should create task filter key by using appName and the username', (done) => { it('should create task filter key by using appName and the username', (done) => {
@ -261,10 +258,6 @@ describe('Inject [LocalPreferenceCloudService] into the TaskFilterCloudService',
spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock); spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
}); });
it('should be able to inject LocalPreferenceCloudService when you override with user preference service', () => {
expect(preferenceCloudService instanceof LocalPreferenceCloudService).toBeTruthy();
});
it('should create default task filters if there are no task filter preferences', (done) => { it('should create default task filters if there are no task filter preferences', (done) => {
const appName = 'fakeAppName'; const appName = 'fakeAppName';
service.getTaskListFilters(appName).subscribe((res) => { service.getTaskListFilters(appName).subscribe((res) => {

View File

@ -1,30 +0,0 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TaskFiltersCloudModule } from './task-filters-cloud.module';
describe('TaskFiltersCloudModule', () => {
let taskFiltersCloudModule: TaskFiltersCloudModule;
beforeEach(() => {
taskFiltersCloudModule = new TaskFiltersCloudModule();
});
it('should create an instance', () => {
expect(taskFiltersCloudModule).toBeTruthy();
});
});

View File

@ -72,10 +72,6 @@ describe('TaskFormCloudComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
}); });
it('should create TaskFormCloudComponent ', () => {
expect(component instanceof TaskFormCloudComponent).toBe(true);
});
describe('Complete button', () => { describe('Complete button', () => {
it('should show complete button when status is ASSIGNED', async(() => { it('should show complete button when status is ASSIGNED', async(() => {
@ -467,10 +463,6 @@ describe('TaskFormWithCustomOutComesComponent', () => {
fixture.destroy(); fixture.destroy();
}); });
it('should create instance of TaskFormWithCustomOutComesComponent', () => {
expect(component instanceof TaskFormWithCustomOutComesComponent).toBe(true, 'should create TaskFormWithCustomOutComesComponent');
});
it('should be able to display and click on cancel button', () => { it('should be able to display and click on cancel button', () => {
fixture.detectChanges(); fixture.detectChanges();
const cancelSpy = spyOn(component, 'onCancel').and.callThrough(); const cancelSpy = spyOn(component, 'onCancel').and.callThrough();

View File

@ -272,10 +272,6 @@ describe('TaskListCloudComponent', () => {
copyFixture.destroy(); copyFixture.destroy();
}); });
it('should create instance of CustomTaskListComponent', () => {
expect(componentCustom instanceof CustomTaskListComponent).toBe(true, 'should create CustomTaskListComponent');
});
it('should fetch custom schemaColumn from html', () => { it('should fetch custom schemaColumn from html', () => {
fixture.detectChanges(); fixture.detectChanges();
expect(componentCustom.taskList.columnList).toBeDefined(); expect(componentCustom.taskList.columnList).toBeDefined();

View File

@ -47,11 +47,6 @@ describe('AttachFileWidgetDialogService', () => {
}); });
}); });
it('should be able to create the service', () => {
expect(service).not.toBeNull();
expect(service).toBeDefined();
});
it('should be able to open the dialog when node has permission', () => { it('should be able to open the dialog when node has permission', () => {
service.openLogin('fake-title', 'fake-action'); service.openLogin('fake-title', 'fake-action');
expect(spyOnDialogOpen).toHaveBeenCalled(); expect(spyOnDialogOpen).toHaveBeenCalled();

View File

@ -68,10 +68,6 @@ describe('FormComponent UI and visibility', () => {
TestBed.resetTestingModule(); TestBed.resetTestingModule();
}); });
it('should create instance of FormComponent', () => {
expect(fixture.componentInstance instanceof FormComponent).toBe(true, 'should create FormComponent');
});
describe('Validation icon', () => { describe('Validation icon', () => {
it('should display valid icon for valid form', () => { it('should display valid icon for valid form', () => {

View File

@ -476,10 +476,6 @@ describe('CustomProcessListComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
}); });
it('should create instance of CustomProcessListComponent', () => {
expect(component instanceof CustomProcessListComponent).toBe(true, 'should create CustomProcessListComponent');
});
it('should fetch custom schemaColumn from html', () => { it('should fetch custom schemaColumn from html', () => {
fixture.detectChanges(); fixture.detectChanges();
expect(component.processList.columns).toBeDefined(); expect(component.processList.columns).toBeDefined();

View File

@ -70,10 +70,6 @@ describe('StartFormComponent', () => {
TestBed.resetTestingModule(); TestBed.resetTestingModule();
}); });
it('should create instance of StartProcessInstanceComponent', () => {
expect(fixture.componentInstance instanceof StartProcessInstanceComponent).toBe(true, 'should create StartProcessInstanceComponent');
});
describe('first step', () => { describe('first step', () => {
describe('without start form', () => { describe('without start form', () => {

View File

@ -752,10 +752,6 @@ describe('CustomTaskListComponent', () => {
fixture.destroy(); fixture.destroy();
}); });
it('should create instance of CustomTaskListComponent', () => {
expect(component instanceof CustomTaskListComponent).toBe(true, 'should create CustomTaskListComponent');
});
it('should fetch custom schemaColumn from html', () => { it('should fetch custom schemaColumn from html', () => {
fixture.detectChanges(); fixture.detectChanges();
expect(component.taskList.columnList).toBeDefined(); expect(component.taskList.columnList).toBeDefined();