Skip to content

Commit

Permalink
[ADF-5415] remove deprecated async method (#7171)
Browse files Browse the repository at this point in the history
* remove deprecated async method

* fix tests and code

* test fixes

* fix tests
  • Loading branch information
DenysVuika committed Jul 12, 2021
1 parent 059aa8b commit a4c3f3a
Show file tree
Hide file tree
Showing 41 changed files with 194 additions and 200 deletions.
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
import { WebscriptComponent } from './webscript.component';
import { ContentTestingModule } from '../testing/content.testing.module';
Expand All @@ -36,7 +36,7 @@ describe('WebscriptComponent', () => {
]
});

beforeEach(async(() => {
beforeEach(() => {
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm';

Expand All @@ -48,7 +48,7 @@ describe('WebscriptComponent', () => {
component.scriptPath = 'fakePath';
component.showData = true;
fixture.detectChanges();
}));
});

describe('View', () => {
it('html wrapper should be present', () => {
Expand Down
Expand Up @@ -89,7 +89,7 @@ export class WebscriptComponent implements OnChanges {
this.clean();
}

return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
this.apiService.getInstance().webScript.executeWebScript('GET', this.scriptPath, this.scriptArgs, this.contextRoot, this.servicePath).then((webScriptData) => {

this.data = webScriptData;
Expand Down
2 changes: 2 additions & 0 deletions lib/core/app-config/app-config.service.spec.ts
Expand Up @@ -21,7 +21,9 @@ import { AppConfigService } from './app-config.service';
import { AppConfigModule } from './app-config.module';
import { ExtensionConfig, ExtensionService } from '@alfresco/adf-extensions';
import { of } from 'rxjs';
import { Injectable } from '@angular/core';

@Injectable({ providedIn: 'root' })
class TestExtensionService extends ExtensionService {

onSetup(config: ExtensionConfig) {
Expand Down
Expand Up @@ -18,7 +18,7 @@
/* tslint:disable:component-selector */

import { Component, Input, SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { CardViewItem } from '../../interfaces/card-view-item.interface';
import { CardItemTypeService } from '../../services/card-item-types.service';
Expand All @@ -40,7 +40,7 @@ describe('CardViewItemDispatcherComponent', () => {
let cardItemTypeService: CardItemTypeService;
let component: CardViewItemDispatcherComponent;

beforeEach(async(() => {
beforeEach(() => {
cardItemTypeService = new CardItemTypeService();
cardItemTypeService.setComponentTypeResolver('shiny-custom-element', () => CardViewShinyCustomElementItemComponent);

Expand All @@ -54,7 +54,7 @@ describe('CardViewItemDispatcherComponent', () => {
});

TestBed.compileComponents();
}));
});

beforeEach(() => {
fixture = TestBed.createComponent(CardViewItemDispatcherComponent);
Expand Down
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ObjectDataTableAdapter } from '../../data/object-datatable-adapter';
import { ObjectDataColumn } from '../../data/object-datacolumn.model';

Expand All @@ -28,8 +28,8 @@ describe('JsonCellComponent', () => {
let component: JsonCellComponent;
let fixture: ComponentFixture<JsonCellComponent>;
let dataTableAdapter: ObjectDataTableAdapter;
let rowData;
let columnData;
let rowData: any;
let columnData: any;

setupTestBed({
imports: [
Expand All @@ -38,10 +38,10 @@ describe('JsonCellComponent', () => {
]
});

beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(JsonCellComponent);
component = fixture.componentInstance;
}));
});

beforeEach(() => {
rowData = {
Expand Down
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ObjectDataTableAdapter } from '../../data/object-datatable-adapter';
import { ObjectDataColumn } from '../../data/object-datacolumn.model';

Expand All @@ -28,8 +28,8 @@ describe('LocationCellComponent', () => {
let component: LocationCellComponent;
let fixture: ComponentFixture<LocationCellComponent>;
let dataTableAdapter: ObjectDataTableAdapter;
let rowData;
let columnData;
let rowData: any;
let columnData: any;

setupTestBed({
imports: [
Expand All @@ -38,10 +38,10 @@ describe('LocationCellComponent', () => {
]
});

beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(LocationCellComponent);
component = fixture.componentInstance;
}));
});

beforeEach(() => {
rowData = {
Expand Down
10 changes: 4 additions & 6 deletions lib/core/form/components/form-list.component.spec.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { of } from 'rxjs';
import { FormService } from '../services/form.service';
import { FormListComponent } from './form-list.component';
Expand All @@ -28,7 +28,7 @@ describe('TaskAttachmentList', () => {
let component: FormListComponent;
let fixture: ComponentFixture<FormListComponent>;
let service: FormService;
let element: any;
let element: HTMLElement;

setupTestBed({
imports: [
Expand All @@ -37,14 +37,12 @@ describe('TaskAttachmentList', () => {
]
});

beforeEach(async(() => {

beforeEach(() => {
fixture = TestBed.createComponent(FormListComponent);
component = fixture.componentInstance;
element = fixture.debugElement.nativeElement;
service = TestBed.inject(FormService);

}));
});

it('should show the forms as a list', async () => {
spyOn(service, 'getForms').and.returnValue(of([
Expand Down
Expand Up @@ -16,7 +16,7 @@
*/

import { SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { ContentService } from '../../../../services';
import { of } from 'rxjs';
Expand Down Expand Up @@ -69,10 +69,10 @@ describe('ContentWidgetComponent', () => {
]
});

beforeEach(async(() => {
beforeEach(() => {
serviceContent = TestBed.inject(ContentService);
processContentService = TestBed.inject(ProcessContentService);
}));
});

beforeEach(() => {
fixture = TestBed.createComponent(ContentWidgetComponent);
Expand Down
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Observable, of } from 'rxjs';
import { FormService } from '../../../services/form.service';
Expand Down Expand Up @@ -54,14 +54,14 @@ describe('DropdownWidgetComponent', () => {
]
});

beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(DropdownWidgetComponent);
widget = fixture.componentInstance;
element = fixture.nativeElement;
formService = TestBed.inject(FormService);
visibilityService = TestBed.inject(WidgetVisibilityService);
widget.field = new FormFieldModel(new FormModel());
}));
});

it('should require field with restUrl', () => {
spyOn(formService, 'getRestFieldValues').and.stub();
Expand Down Expand Up @@ -125,12 +125,12 @@ describe('DropdownWidgetComponent', () => {

describe('when is required', () => {

beforeEach(async(() => {
beforeEach(() => {
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>' }), {
type: FormFieldTypes.DROPDOWN,
required: true
});
}));
});

it('should be able to display label with asterix', async () => {
const label = 'MyLabel123';
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('DropdownWidgetComponent', () => {

describe('and dropdown is populated via taskId', () => {

beforeEach(async(() => {
beforeEach(() => {
spyOn(visibilityService, 'refreshVisibility').and.stub();
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
return of(fakeOptionList);
Expand All @@ -180,7 +180,7 @@ describe('DropdownWidgetComponent', () => {
widget.field.emptyOption = { id: 'empty', name: 'Choose one...' };
widget.field.isVisible = true;
fixture.detectChanges();
}));
});

it('should show visible dropdown widget', async () => {
expect(element.querySelector('#dropdown-id')).toBeDefined();
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('DropdownWidgetComponent', () => {

describe('and dropdown is populated via processDefinitionId', () => {

beforeEach(async(() => {
beforeEach(() => {
spyOn(visibilityService, 'refreshVisibility').and.stub();
spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => {
return of(fakeOptionList);
Expand All @@ -243,7 +243,7 @@ describe('DropdownWidgetComponent', () => {
widget.field.emptyOption = { id: 'empty', name: 'Choose one...' };
widget.field.isVisible = true;
fixture.detectChanges();
}));
});

it('should show visible dropdown widget', () => {
expect(element.querySelector('#dropdown-id')).toBeDefined();
Expand Down
6 changes: 3 additions & 3 deletions lib/core/form/components/widgets/tabs/tabs.widget.spec.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { tick, fakeAsync, async, ComponentFixture, TestBed, flush } from '@angular/core/testing';
import { tick, fakeAsync, ComponentFixture, TestBed, flush } from '@angular/core/testing';
import { fakeFormJson } from '../../../../mock';
import { FormFieldModel } from '../core/form-field.model';
import { FormModel } from '../core/form.model';
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('TabsWidgetComponent', () => {
let fakeTabVisible: TabModel;
let fakeTabInvisible: TabModel;

beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(TabsWidgetComponent);
tabWidgetComponent = fixture.componentInstance;
element = fixture.nativeElement;
Expand All @@ -105,7 +105,7 @@ describe('TabsWidgetComponent', () => {
fakeTabInvisible.isVisible = false;
tabWidgetComponent.tabs.push(fakeTabVisible);
tabWidgetComponent.tabs.push(fakeTabInvisible);
}));
});

it('should show only visible tabs', fakeAsync(() => {
fixture.detectChanges();
Expand Down
22 changes: 12 additions & 10 deletions lib/core/login/components/login-dialog-panel.component.spec.ts
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthenticationService } from '../../services/authentication.service';
import { LoginDialogPanelComponent } from './login-dialog-panel.component';
import { of } from 'rxjs';
Expand All @@ -26,8 +26,9 @@ import { TranslateModule } from '@ngx-translate/core';
describe('LoginDialogPanelComponent', () => {
let component: LoginDialogPanelComponent;
let fixture: ComponentFixture<LoginDialogPanelComponent>;
let element: any;
let usernameInput, passwordInput;
let element: HTMLElement;
let usernameInput: HTMLInputElement;
let passwordInput: HTMLInputElement;
let authService: AuthenticationService;

setupTestBed({
Expand All @@ -37,23 +38,24 @@ describe('LoginDialogPanelComponent', () => {
]
});

beforeEach(async(() => {
beforeEach(async () => {
fixture = TestBed.createComponent(LoginDialogPanelComponent);
element = fixture.nativeElement;
component = fixture.componentInstance;
authService = TestBed.inject(AuthenticationService);

fixture.detectChanges();
fixture.whenStable().then(() => {
usernameInput = element.querySelector('#username');
passwordInput = element.querySelector('#password');
});
}));
await fixture.whenStable();

usernameInput = element.querySelector('#username');
passwordInput = element.querySelector('#password');
});

afterEach(() => {
fixture.destroy();
});

function loginWithCredentials(username, password) {
function loginWithCredentials(username: string, password: string) {
usernameInput.value = username;
passwordInput.value = password;

Expand Down
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { setupTestBed } from '../../testing/setup-test-bed';
import { CoreTestingModule } from '../../testing/core.testing.module';
import { NotificationHistoryComponent } from './notification-history.component';
Expand Down Expand Up @@ -48,15 +48,15 @@ describe('Notification History Component', () => {
]
});

beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(NotificationHistoryComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;

storage = TestBed.inject(StorageService);
notificationService = TestBed.inject(NotificationService);
component.notifications = [];
}));
});

beforeEach(inject([OverlayContainer], (oc: OverlayContainer) => {
overlayContainerElement = oc.getContainerElement();
Expand Down

0 comments on commit a4c3f3a

Please sign in to comment.