enable prefer-const rule for tslint, fix issues (#4409)

* enable prefer-const rule for tslint, fix issues

* Update content-node-selector.component.spec.ts

* Update content-node-selector.component.spec.ts

* fix const

* fix lint issues

* update tests

* update tests

* update tests

* fix code

* fix page class
This commit is contained in:
Denys Vuika
2019-03-25 12:19:33 +00:00
committed by Eugenio Romano
parent 26c5982a1a
commit a7a48e8b2b
581 changed files with 5435 additions and 5402 deletions

View File

@@ -29,11 +29,11 @@ describe('CreateProcessAttachmentComponent', () => {
let fixture: ComponentFixture<CreateProcessAttachmentComponent>;
let element: HTMLElement;
let file = new File([new Blob()], 'Test');
let fileObj = { entry: null, file: file, relativeFolder: '/' };
let customEvent = { detail: { files: [fileObj] } };
const file = new File([new Blob()], 'Test');
const fileObj = { entry: null, file: file, relativeFolder: '/' };
const customEvent = { detail: { files: [fileObj] } };
let fakeUploadResponse = {
const fakeUploadResponse = {
id: 9999,
name: 'BANANA.jpeg',
created: '2017-06-12T12:52:11.109Z',
@@ -73,7 +73,7 @@ describe('CreateProcessAttachmentComponent', () => {
it('should update the processInstanceId when it is changed', () => {
component.processInstanceId = null;
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
expect(component.processInstanceId).toBe('123');
@@ -96,7 +96,7 @@ describe('CreateProcessAttachmentComponent', () => {
}));
it('should allow user to upload files via button', async(() => {
let buttonUpload: HTMLElement = <HTMLElement> element.querySelector('#add_new_process_content_button');
const buttonUpload: HTMLElement = <HTMLElement> element.querySelector('#add_new_process_content_button');
expect(buttonUpload).toBeDefined();
expect(buttonUpload).not.toBeNull();
@@ -106,7 +106,7 @@ describe('CreateProcessAttachmentComponent', () => {
expect(res.id).toBe(9999);
});
let dropEvent = new CustomEvent('upload-files', customEvent);
const dropEvent = new CustomEvent('upload-files', customEvent);
buttonUpload.dispatchEvent(dropEvent);
fixture.detectChanges();

View File

@@ -51,11 +51,11 @@ export class CreateProcessAttachmentComponent implements OnChanges {
}
onFileUpload(event: any) {
let filesList: File[] = event.detail.files.map((obj) => obj.file);
const filesList: File[] = event.detail.files.map((obj) => obj.file);
for (let fileInfoObj of filesList) {
let file: File = fileInfoObj;
let opts = {
for (const fileInfoObj of filesList) {
const file: File = fileInfoObj;
const opts = {
isRelatedContent: true
};
this.activitiContentService.createProcessRelatedContent(this.processInstanceId, file, opts).subscribe(

View File

@@ -47,15 +47,15 @@ describe('AttachmentComponent', () => {
});
it('should not call createTaskRelatedContent service when taskId changed', () => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'taskId': change});
expect(createTaskRelatedContentSpy).not.toHaveBeenCalled();
});
it('should not call createTaskRelatedContent service when there is no file uploaded', () => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'taskId': change});
let customEvent: any = {
const customEvent: any = {
detail: {
files: []
}
@@ -65,10 +65,10 @@ describe('AttachmentComponent', () => {
});
it('should call createTaskRelatedContent service when there is a file uploaded', () => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'taskId': change});
let file = new File([new Blob()], 'Test');
let customEvent = {
const file = new File([new Blob()], 'Test');
const customEvent = {
detail: {
files: [
file

View File

@@ -51,11 +51,11 @@ export class AttachmentComponent implements OnChanges {
}
onFileUpload(event: any) {
let filesList: File[] = event.detail.files.map((obj) => obj.file);
const filesList: File[] = event.detail.files.map((obj) => obj.file);
for (let fileInfoObj of filesList) {
let file: File = fileInfoObj;
let opts = {
for (const fileInfoObj of filesList) {
const file: File = fileInfoObj;
const opts = {
isRelatedContent: true
};
this.activitiContentService.createTaskRelatedContent(this.taskId, file, opts).subscribe(

View File

@@ -90,7 +90,7 @@ describe('ProcessAttachmentListComponent', () => {
getProcessRelatedContentSpy = spyOn(service, 'getProcessRelatedContent').and.returnValue(of(mockAttachment));
spyOn(service, 'deleteRelatedContent').and.returnValue(of({successCode: true}));
let blobObj = new Blob();
const blobObj = new Blob();
spyOn(service, 'getFileRawContent').and.returnValue(of(blobObj));
});
@@ -104,21 +104,21 @@ describe('ProcessAttachmentListComponent', () => {
});
it('should load attachments when processInstanceId specified', () => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
expect(getProcessRelatedContentSpy).toHaveBeenCalled();
});
it('should emit an error when an error occurs loading attachments', () => {
let emitSpy = spyOn(component.error, 'emit');
const emitSpy = spyOn(component.error, 'emit');
getProcessRelatedContentSpy.and.returnValue(throwError({}));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
expect(emitSpy).toHaveBeenCalled();
});
it('should emit a success event when the attachments are loaded', () => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.success.subscribe((attachments) => {
expect(attachments[0].name).toEqual(mockAttachment.data[0].name);
expect(attachments[0].id).toEqual(mockAttachment.data[0].id);
@@ -133,7 +133,7 @@ describe('ProcessAttachmentListComponent', () => {
});
it('should display attachments when the process has attachments', async(() => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
fixture.detectChanges();
@@ -143,15 +143,15 @@ describe('ProcessAttachmentListComponent', () => {
}));
it('should display all actions if attachments are not read only', async(() => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
fixture.detectChanges();
let actionButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="action_menu_0"]');
const actionButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="action_menu_0"]');
actionButton.click();
fixture.whenStable().then(() => {
fixture.detectChanges();
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
const actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
@@ -160,16 +160,16 @@ describe('ProcessAttachmentListComponent', () => {
}));
it('should not display remove action if attachments are read only', async(() => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
component.disabled = true;
fixture.detectChanges();
let actionButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="action_menu_0"]');
const actionButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="action_menu_0"]');
actionButton.click();
fixture.whenStable().then(() => {
fixture.detectChanges();
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
const actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).toBeNull();
@@ -184,7 +184,7 @@ describe('ProcessAttachmentListComponent', () => {
'start': 0,
'data': []
}));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'processInstanceId': change});
fixture.whenStable().then(() => {
fixture.detectChanges();
@@ -199,7 +199,7 @@ describe('ProcessAttachmentListComponent', () => {
'start': 0,
'data': []
}));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'processInstanceId': change});
component.disabled = true;
@@ -217,7 +217,7 @@ describe('ProcessAttachmentListComponent', () => {
'start': 0,
'data': []
}));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'processInstanceId': change});
component.disabled = true;
@@ -230,7 +230,7 @@ describe('ProcessAttachmentListComponent', () => {
it('should not show the empty list component when the attachments list is not empty for completed process', async(() => {
getProcessRelatedContentSpy.and.returnValue(of(mockAttachment));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({'processInstanceId': change});
component.disabled = true;
@@ -251,8 +251,8 @@ describe('ProcessAttachmentListComponent', () => {
describe('change detection', () => {
let change = new SimpleChange('123', '456', true);
let nullChange = new SimpleChange('123', null, true);
const change = new SimpleChange('123', '456', true);
const nullChange = new SimpleChange('123', null, true);
beforeEach(async(() => {
component.processInstanceId = '123';
@@ -325,7 +325,7 @@ describe('Custom CustomEmptyTemplateComponent', () => {
it('should render the custom template', async(() => {
fixture.whenStable().then(() => {
fixture.detectChanges();
let title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
const title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
expect(title.length).toBe(1);
expect(title[0].nativeElement.innerText).toBe('Custom header');
});

View File

@@ -152,17 +152,17 @@ export class ProcessAttachmentListComponent implements OnChanges, AfterContentIn
}
onShowRowActionsMenu(event: any) {
let viewAction = {
const viewAction = {
title: 'ADF_PROCESS_LIST.MENU_ACTIONS.VIEW_CONTENT',
name: 'view'
};
let removeAction = {
const removeAction = {
title: 'ADF_PROCESS_LIST.MENU_ACTIONS.REMOVE_CONTENT',
name: 'remove'
};
let downloadAction = {
const downloadAction = {
title: 'ADF_PROCESS_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT',
name: 'download'
};
@@ -178,8 +178,8 @@ export class ProcessAttachmentListComponent implements OnChanges, AfterContentIn
}
onExecuteRowAction(event: any) {
let args = event.value;
let action = args.action;
const args = event.value;
const action = args.action;
if (action.name === 'view') {
this.emitDocumentContent(args.row.obj);
} else if (action.name === 'remove') {
@@ -190,7 +190,7 @@ export class ProcessAttachmentListComponent implements OnChanges, AfterContentIn
}
openContent(event: any): void {
let content = event.value.obj;
const content = event.value.obj;
this.emitDocumentContent(content);
}

View File

@@ -86,7 +86,7 @@ describe('TaskAttachmentList', () => {
deleteContentSpy = spyOn(service, 'deleteRelatedContent').and.returnValue(of({ successCode: true }));
let blobObj = new Blob();
const blobObj = new Blob();
getFileRawContentSpy = spyOn(service, 'getFileRawContent').and.returnValue(of(blobObj));
});
@@ -102,21 +102,21 @@ describe('TaskAttachmentList', () => {
});
it('should load attachments when taskId specified', () => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
expect(getTaskRelatedContentSpy).toHaveBeenCalled();
});
it('should emit an error when an error occurs loading attachments', () => {
let emitSpy = spyOn(component.error, 'emit');
const emitSpy = spyOn(component.error, 'emit');
getTaskRelatedContentSpy.and.returnValue(throwError({}));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
expect(emitSpy).toHaveBeenCalled();
});
it('should emit a success event when the attachments are loaded', () => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
disposableSuccess = component.success.subscribe((attachments) => {
expect(attachments[0].name).toEqual(mockAttachment.data[0].name);
expect(attachments[0].id).toEqual(mockAttachment.data[0].id);
@@ -131,7 +131,7 @@ describe('TaskAttachmentList', () => {
});
it('should display attachments when the task has attachments', (done) => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
fixture.detectChanges();
@@ -160,7 +160,7 @@ describe('TaskAttachmentList', () => {
'start': 0,
'data': []
}));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
component.hasCustomTemplate = false;
@@ -172,15 +172,15 @@ describe('TaskAttachmentList', () => {
}));
it('should display all actions if attachments are not read only', async(() => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
fixture.detectChanges();
let actionButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="action_menu_0"]');
const actionButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="action_menu_0"]');
actionButton.click();
fixture.whenStable().then(() => {
fixture.detectChanges();
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
const actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
@@ -189,16 +189,16 @@ describe('TaskAttachmentList', () => {
}));
it('should not display remove action if attachments are read only', async(() => {
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
component.disabled = true;
fixture.detectChanges();
let actionButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="action_menu_0"]');
const actionButton = fixture.debugElement.nativeElement.querySelector('[data-automation-id="action_menu_0"]');
actionButton.click();
fixture.whenStable().then(() => {
fixture.detectChanges();
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
const actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).toBeNull();
@@ -213,7 +213,7 @@ describe('TaskAttachmentList', () => {
'start': 0,
'data': []
}));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
fixture.detectChanges();
fixture.whenStable().then(() => {
@@ -229,7 +229,7 @@ describe('TaskAttachmentList', () => {
'start': 0,
'data': []
}));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
component.disabled = true;
@@ -241,7 +241,7 @@ describe('TaskAttachmentList', () => {
it('should not show the empty list component when the attachments list is not empty for completed task', (done) => {
getTaskRelatedContentSpy.and.returnValue(of(mockAttachment));
let change = new SimpleChange(null, '123', true);
const change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
component.disabled = true;
@@ -346,7 +346,7 @@ describe('Custom CustomEmptyTemplateComponent', () => {
it('should render the custom template', async(() => {
fixture.whenStable().then(() => {
fixture.detectChanges();
let title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
const title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
expect(title.length).toBe(1);
expect(title[0].nativeElement.innerText).toBe('Custom header');
});

View File

@@ -122,7 +122,7 @@ export class TaskAttachmentListComponent implements OnChanges, AfterContentInit
const opts = 'true';
this.activitiContentService.getTaskRelatedContent(taskId, opts).subscribe(
(res: any) => {
let attachList = [];
const attachList = [];
res.data.forEach((content) => {
attachList.push({
id: content.id,
@@ -162,17 +162,17 @@ export class TaskAttachmentListComponent implements OnChanges, AfterContentInit
}
onShowRowActionsMenu(event: any) {
let viewAction = {
const viewAction = {
title: 'ADF_TASK_LIST.MENU_ACTIONS.VIEW_CONTENT',
name: 'view'
};
let removeAction = {
const removeAction = {
title: 'ADF_TASK_LIST.MENU_ACTIONS.REMOVE_CONTENT',
name: 'remove'
};
let downloadAction = {
const downloadAction = {
title: 'ADF_TASK_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT',
name: 'download'
};
@@ -188,8 +188,8 @@ export class TaskAttachmentListComponent implements OnChanges, AfterContentInit
}
onExecuteRowAction(event: any) {
let args = event.value;
let action = args.action;
const args = event.value;
const action = args.action;
if (action.name === 'view') {
this.emitDocumentContent(args.row.obj);
} else if (action.name === 'remove') {
@@ -200,7 +200,7 @@ export class TaskAttachmentListComponent implements OnChanges, AfterContentInit
}
openContent(event: any): void {
let content = event.value.obj;
const content = event.value.obj;
this.emitDocumentContent(content);
}