[ADF-5415] remove deprecated async method (#7171)

* remove deprecated async method

* fix tests and code

* test fixes

* fix tests
This commit is contained in:
Denys Vuika
2021-07-12 20:09:47 +01:00
committed by GitHub
parent 059aa8ba06
commit a4c3f3a95b
41 changed files with 194 additions and 200 deletions

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ContentModule, ContentNodeSelectorPanelComponent, DocumentListService } from '@alfresco/adf-content-services';
import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
@@ -63,7 +63,7 @@ describe('AttachFileWidgetDialogComponent', () => {
schemas: [NO_ERRORS_SCHEMA]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(AttachFileWidgetDialogComponent);
widget = fixture.componentInstance;
element = fixture.nativeElement;
@@ -83,7 +83,7 @@ describe('AttachFileWidgetDialogComponent', () => {
spyOn(widget, 'isLoggedIn').and.callFake(() => {
return isLogged;
});
}));
});
afterEach(() => {
fixture.destroy();
@@ -96,10 +96,10 @@ describe('AttachFileWidgetDialogComponent', () => {
describe('When is not logged in', () => {
beforeEach(async(() => {
beforeEach(() => {
fixture.detectChanges();
isLogged = false;
}));
});
it('should show the login form', () => {
expect(element.querySelector('#attach-file-login-panel')).not.toBeNull();
@@ -135,11 +135,11 @@ describe('AttachFileWidgetDialogComponent', () => {
let contentNodePanel;
beforeEach(async(() => {
beforeEach(() => {
isLogged = true;
fixture.detectChanges();
contentNodePanel = fixture.debugElement.query(By.directive(ContentNodeSelectorPanelComponent));
}));
});
it('should show the content node selector', () => {
expect(element.querySelector('#attach-file-content-node')).not.toBeNull();
@@ -175,21 +175,21 @@ describe('AttachFileWidgetDialogComponent', () => {
});
describe('login only', () => {
beforeEach(async(() => {
beforeEach(() => {
spyOn(authService, 'login').and.returnValue(of({ type: 'type', ticket: 'ticket'}));
spyOn(matDialogRef, 'close').and.callThrough();
fixture.detectChanges();
widget.data.loginOnly = true;
widget.data.registerExternalHost = () => {};
isLogged = false;
}));
});
it('should close the dialog once user loggedIn', () => {
fixture.detectChanges();
isLogged = true;
const loginButton: HTMLButtonElement = element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]');
const usernameInput: HTMLInputElement = element.querySelector('#username');
const passwordInput: HTMLInputElement = element.querySelector('#password');
const loginButton = element.querySelector<HTMLButtonElement>('button[data-automation-id="attach-file-dialog-actions-login"]');
const usernameInput = element.querySelector<HTMLInputElement>('#username');
const passwordInput = element.querySelector<HTMLInputElement>('#password');
usernameInput.value = 'fake-user';
passwordInput.value = 'fake-user';
usernameInput.dispatchEvent(new Event('input'));
@@ -211,9 +211,9 @@ describe('AttachFileWidgetDialogComponent', () => {
describe('Attach button', () => {
beforeEach(async(() => {
beforeEach(() => {
isLogged = true;
}));
});
it('should be disabled by default', () => {
fixture.detectChanges();

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UserProcessModel, setupTestBed, DataRowActionEvent, DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
import { UserEventModel } from '../../../task-list/models/user-event.model';
import { PeopleListComponent } from './people-list.component';
@@ -41,11 +41,11 @@ describe('PeopleListComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(PeopleListComponent);
peopleListComponent = fixture.componentInstance;
fixture.detectChanges();
}));
});
it('should emit row click event', (done) => {
const row = new ObjectDataRow(fakeUser);

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UserProcessModel, setupTestBed } from '@alfresco/adf-core';
import { of } from 'rxjs';
import { PeopleSearchComponent } from './people-search.component';
@@ -51,13 +51,13 @@ describe('PeopleSearchComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(PeopleSearchComponent);
peopleSearchComponent = fixture.componentInstance;
element = fixture.nativeElement;
peopleSearchComponent.results = of([]);
fixture.detectChanges();
}));
});
it('should show input search text', () => {
expect(element.querySelector('#userSearchText')).toBeDefined();

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { ProcessNamePipe } from './process-name.pipe';
import { setupTestBed } from 'core';
import { CoreTestingModule } from 'core/testing/core.testing.module';
@@ -30,7 +30,7 @@ describe('ProcessNamePipe', () => {
const defaultName = 'default-name';
const datetimeIdentifier = '%{datetime}';
const processDefinitionIdentifier = '%{processDefinition}';
const mockCurrentDate = new Date('Wed Oct 23 2019');
const mockCurrentDate: number = new Date('Wed Oct 23 2019').getTime();
const mockLocalizedCurrentDate = 'Oct 23, 2019, 12:00:00 AM';
const nameWithProcessDefinitionIdentifier = `${defaultName} - ${processDefinitionIdentifier}`;
const nameWithDatetimeIdentifier = `${defaultName} - ${datetimeIdentifier}`;
@@ -44,10 +44,10 @@ describe('ProcessNamePipe', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
const localizedDatePipe = TestBed.inject(LocalizedDatePipe);
processNamePipe = new ProcessNamePipe(localizedDatePipe);
}));
});
it('should not modify the name when there is no identifier', () => {
const transformResult = processNamePipe.transform(defaultName);

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { setupTestBed, LogService } from '@alfresco/adf-core';
import { of, throwError } from 'rxjs';
import { TaskListService } from '../services/tasklist.service';
@@ -56,7 +56,7 @@ describe('StartTaskComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(StartTaskComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
@@ -67,7 +67,7 @@ describe('StartTaskComponent', () => {
getFormListSpy = spyOn(service, 'getFormList').and.returnValue(of(fakeForms$));
fixture.detectChanges();
}));
});
afterEach(() => {
fixture.destroy();

View File

@@ -16,12 +16,7 @@
*/
import { Component } from '@angular/core';
import {
async,
ComponentFixture,
fakeAsync,
TestBed
} from '@angular/core/testing';
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
import { of } from 'rxjs';
import { TaskListService } from './../services/tasklist.service';
import { setupTestBed } from '@alfresco/adf-core';
@@ -83,13 +78,13 @@ describe('TaskAuditDirective', () => {
declarations: [BasicButtonComponent]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(BasicButtonComponent);
component = fixture.componentInstance;
service = TestBed.inject(TaskListService);
jasmine.Ajax.install();
}));
});
afterEach(() => {
jasmine.Ajax.uninstall();

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { fakeAppPromise } from '../../mock';
import { fakeFiltersResponse, fakeAppFilter } from '../../mock/task/task-filters.mock';
import { FilterRepresentationModel } from '../models/filter.model';
@@ -36,10 +36,10 @@ describe('Activiti Task filter Service', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
service = TestBed.inject(TaskFilterService);
jasmine.Ajax.install();
}));
});
afterEach(() => {
jasmine.Ajax.uninstall();

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { UserProcessModel, setupTestBed, CoreModule } from '@alfresco/adf-core';
import { of } from 'rxjs';
import {
@@ -49,10 +49,10 @@ describe('Activiti TaskList Service', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
service = TestBed.inject(TaskListService);
jasmine.Ajax.install();
}));
});
afterEach(() => {
jasmine.Ajax.uninstall();