[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 { 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';
@@ -36,7 +36,7 @@ describe('WebscriptComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
@@ -48,7 +48,7 @@ describe('WebscriptComponent', () => {
component.scriptPath = 'fakePath';
component.showData = true;
fixture.detectChanges();
}));
});
describe('View', () => {
it('html wrapper should be present', () => {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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';
@@ -40,7 +40,7 @@ describe('CardViewItemDispatcherComponent', () => {
let cardItemTypeService: CardItemTypeService;
let component: CardViewItemDispatcherComponent;
beforeEach(async(() => {
beforeEach(() => {
cardItemTypeService = new CardItemTypeService();
cardItemTypeService.setComponentTypeResolver('shiny-custom-element', () => CardViewShinyCustomElementItemComponent);
@@ -54,7 +54,7 @@ describe('CardViewItemDispatcherComponent', () => {
});
TestBed.compileComponents();
}));
});
beforeEach(() => {
fixture = TestBed.createComponent(CardViewItemDispatcherComponent);

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 { ObjectDataTableAdapter } from '../../data/object-datatable-adapter';
import { ObjectDataColumn } from '../../data/object-datacolumn.model';
@@ -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: [
@@ -38,10 +38,10 @@ describe('JsonCellComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(JsonCellComponent);
component = fixture.componentInstance;
}));
});
beforeEach(() => {
rowData = {

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 { ObjectDataTableAdapter } from '../../data/object-datatable-adapter';
import { ObjectDataColumn } from '../../data/object-datacolumn.model';
@@ -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: [
@@ -38,10 +38,10 @@ describe('LocationCellComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(LocationCellComponent);
component = fixture.componentInstance;
}));
});
beforeEach(() => {
rowData = {

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 { of } from 'rxjs';
import { FormService } from '../services/form.service';
import { FormListComponent } from './form-list.component';
@@ -28,7 +28,7 @@ describe('TaskAttachmentList', () => {
let component: FormListComponent;
let fixture: ComponentFixture<FormListComponent>;
let service: FormService;
let element: any;
let element: HTMLElement;
setupTestBed({
imports: [
@@ -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([

View File

@@ -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';
@@ -69,10 +69,10 @@ describe('ContentWidgetComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
serviceContent = TestBed.inject(ContentService);
processContentService = TestBed.inject(ProcessContentService);
}));
});
beforeEach(() => {
fixture = TestBed.createComponent(ContentWidgetComponent);

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 { By } from '@angular/platform-browser';
import { Observable, of } from 'rxjs';
import { FormService } from '../../../services/form.service';
@@ -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();
@@ -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';
@@ -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);
@@ -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();
@@ -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);
@@ -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();

View File

@@ -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';
@@ -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;
@@ -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();

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 { AuthenticationService } from '../../services/authentication.service';
import { LoginDialogPanelComponent } from './login-dialog-panel.component';
import { of } from 'rxjs';
@@ -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({
@@ -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(() => {
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;

View File

@@ -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';
@@ -48,7 +48,7 @@ describe('Notification History Component', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(NotificationHistoryComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
@@ -56,7 +56,7 @@ describe('Notification History Component', () => {
storage = TestBed.inject(StorageService);
notificationService = TestBed.inject(NotificationService);
component.notifications = [];
}));
});
beforeEach(inject([OverlayContainer], (oc: OverlayContainer) => {
overlayContainerElement = oc.getContainerElement();

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { AppConfigService } from '../app-config/app-config.service';
import { UserPreferencesService } from '../services/user-preferences.service';
import { of } from 'rxjs';
@@ -36,11 +36,11 @@ describe('DecimalNumberPipe', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
userPreferences = TestBed.inject(UserPreferencesService);
spyOn(userPreferences, 'select').and.returnValue(of(''));
pipe = new DecimalNumberPipe(userPreferences, TestBed.inject(AppConfigService));
}));
});
it('should return number localized and rounded following the default config', () => {
expect(pipe.transform(1234.567)).toBe('1,234.57');

View File

@@ -16,16 +16,15 @@
*/
import { FileTypePipe } from './file-type.pipe';
import { async } from '@angular/core/testing';
describe('FileTypePipe', () => {
const altText = 'ft_ic_ms_word';
let pipe: FileTypePipe;
beforeEach(async(() => {
beforeEach(() => {
pipe = new FileTypePipe();
}));
});
it('should return file type from alt text', () => {
expect(pipe.transform(altText)).toBe('word');

View File

@@ -16,15 +16,14 @@
*/
import { FullNamePipe } from './full-name.pipe';
import { async } from '@angular/core/testing';
describe('FullNamePipe', () => {
let pipe: FullNamePipe;
beforeEach(async(() => {
beforeEach(() => {
pipe = new FullNamePipe();
}));
});
it('should return empty string when there is no name', () => {
const user = {};

View File

@@ -16,7 +16,7 @@
*/
import { LocalizedDatePipe } from './localized-date.pipe';
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { AppConfigService } from '../app-config/app-config.service';
import { UserPreferencesService } from '../services/user-preferences.service';
import { of } from 'rxjs';
@@ -39,11 +39,11 @@ describe('LocalizedDatePipe', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
userPreferences = TestBed.inject(UserPreferencesService);
spyOn(userPreferences, 'select').and.returnValue(of(''));
pipe = new LocalizedDatePipe(userPreferences, TestBed.inject(AppConfigService));
}));
});
it('should return time with locale en-US', () => {
const date = new Date('1990-11-03 00:00');

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { ActivatedRouteSnapshot, Router } from '@angular/router';
import { setupTestBed } from '../testing/setup-test-bed';
import { CoreTestingModule } from '../testing/core.testing.module';
@@ -49,7 +49,7 @@ describe('Auth Guard SSO role service', () => {
peopleContentService = TestBed.inject(PeopleContentService);
});
it('Should canActivate be true if the Role is present int the JWT token', async(async () => {
it('Should canActivate be true if the Role is present int the JWT token', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
@@ -57,9 +57,9 @@ describe('Auth Guard SSO role service', () => {
router.data = { 'roles': ['role1', 'role2'] };
expect(await authGuard.canActivate(router)).toBeTruthy();
}));
});
it('Should canActivate be false if the Role is not present int the JWT token', async(async () => {
it('Should canActivate be false if the Role is not present int the JWT token', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role3'] } });
@@ -67,9 +67,9 @@ describe('Auth Guard SSO role service', () => {
router.data = { 'roles': ['role1', 'role2'] };
expect(await authGuard.canActivate(router)).toBeFalsy();
}));
});
it('Should not redirect if canActivate is', async(async () => {
it('Should not redirect if canActivate is', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
spyOn(routerService, 'navigate').and.stub();
@@ -79,27 +79,27 @@ describe('Auth Guard SSO role service', () => {
expect(await authGuard.canActivate(router)).toBeTruthy();
expect(routerService.navigate).not.toHaveBeenCalled();
}));
});
it('Should canActivate return false if the data Role to check is empty', async(async () => {
it('Should canActivate return false if the data Role to check is empty', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1', 'role3'] } });
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
expect(await authGuard.canActivate(router)).toBeFalsy();
}));
});
it('Should canActivate return false if the realm_access is not present', async(async () => {
it('Should canActivate return false if the realm_access is not present', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({});
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
expect(await authGuard.canActivate(router)).toBeFalsy();
}));
});
it('Should redirect to the redirectURL if canActivate is false and redirectUrl is in data', async(async () => {
it('Should redirect to the redirectURL if canActivate is false and redirectUrl is in data', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({});
spyOn(routerService, 'navigate').and.stub();
@@ -109,9 +109,9 @@ describe('Auth Guard SSO role service', () => {
expect(await authGuard.canActivate(router)).toBeFalsy();
expect(routerService.navigate).toHaveBeenCalledWith(['/no-role-url']);
}));
});
it('Should not redirect if canActivate is false and redirectUrl is not in data', async(async () => {
it('Should not redirect if canActivate is false and redirectUrl is not in data', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({});
spyOn(routerService, 'navigate').and.stub();
@@ -121,7 +121,7 @@ describe('Auth Guard SSO role service', () => {
expect(await authGuard.canActivate(router)).toBeFalsy();
expect(routerService.navigate).not.toHaveBeenCalled();
}));
});
it('Should canActivate be false hasRealm is true and hasClientRole is false', async () => {
const route: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { Router, RouterStateSnapshot } from '@angular/router';
import { AppConfigService } from '../app-config/app-config.service';
import { AuthGuard } from './auth-guard.service';
@@ -53,33 +53,33 @@ describe('AuthGuardService', () => {
storageService = TestBed.inject(StorageService);
});
it('if the alfresco js api is logged in should canActivate be true', async(async () => {
it('if the alfresco js api is logged in should canActivate be true', async () => {
spyOn(router, 'navigateByUrl');
spyOn(authService, 'isLoggedIn').and.returnValue(true);
expect(await authGuard.canActivate(null, state)).toBeTruthy();
expect(router.navigateByUrl).not.toHaveBeenCalled();
}));
});
it('if the alfresco js api is NOT logged in should canActivate be false', async(async () => {
it('if the alfresco js api is NOT logged in should canActivate be false', async () => {
state.url = 'some-url';
spyOn(router, 'navigateByUrl');
spyOn(authService, 'isLoggedIn').and.returnValue(false);
expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
});
it('if the alfresco js api is configured with withCredentials true should canActivate be true', async(async () => {
it('if the alfresco js api is configured with withCredentials true should canActivate be true', async () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
appConfigService.config.auth.withCredentials = true;
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
expect(await authGuard.canActivate(null, route)).toBeTruthy();
}));
});
it('should not redirect to login', async(async () => {
it('should not redirect to login', async () => {
storageService.setItem('loginFragment', 'login');
spyOn(router, 'navigateByUrl').and.stub();
@@ -89,9 +89,9 @@ describe('AuthGuardService', () => {
expect(await authGuard.canActivate(null, state)).toBeTruthy();
expect(router.navigateByUrl).not.toHaveBeenCalled();
}));
});
it('should redirect url if the User is NOT logged in and isOAuthWithoutSilentLogin', async(async () => {
it('should redirect url if the User is NOT logged in and isOAuthWithoutSilentLogin', async () => {
spyOn(router, 'navigateByUrl').and.stub();
spyOn(authService, 'isLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
@@ -99,9 +99,9 @@ describe('AuthGuardService', () => {
expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
});
it('should redirect url if the User is NOT logged in and isOAuth but no silentLogin configured', async(async () => {
it('should redirect url if the User is NOT logged in and isOAuth but no silentLogin configured', async () => {
spyOn(router, 'navigateByUrl').and.stub();
spyOn(authService, 'isLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
@@ -109,9 +109,9 @@ describe('AuthGuardService', () => {
expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
}));
});
it('should NOT redirect url if the User is NOT logged in and isOAuth but with silentLogin configured', async(async () => {
it('should NOT redirect url if the User is NOT logged in and isOAuth but with silentLogin configured', async () => {
spyOn(authService, 'ssoImplicitLogin').and.stub();
spyOn(authService, 'isLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
@@ -119,9 +119,9 @@ describe('AuthGuardService', () => {
expect(await authGuard.canActivate(null, state)).toBeFalsy();
expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1);
}));
});
it('should set redirect url', async(async () => {
it('should set redirect url', async () => {
state.url = 'some-url';
appConfigService.config.loginRoute = 'login';
@@ -134,9 +134,9 @@ describe('AuthGuardService', () => {
provider: 'ALL', url: 'some-url'
});
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url'));
}));
});
it('should set redirect url with query params', async(async () => {
it('should set redirect url with query params', async () => {
state.url = 'some-url;q=query';
appConfigService.config.loginRoute = 'login';
appConfigService.config.provider = 'ALL';
@@ -150,9 +150,9 @@ describe('AuthGuardService', () => {
provider: 'ALL', url: 'some-url;q=query'
});
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url;q=query'));
}));
});
it('should get redirect url from config if there is one configured', async(async () => {
it('should get redirect url from config if there is one configured', async () => {
state.url = 'some-url';
appConfigService.config.loginRoute = 'fakeLoginRoute';
@@ -165,9 +165,9 @@ describe('AuthGuardService', () => {
provider: 'ALL', url: 'some-url'
});
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/fakeLoginRoute?redirectUrl=some-url'));
}));
});
it('should pass actual redirect when no state segments exists', async(async () => {
it('should pass actual redirect when no state segments exists', async () => {
state.url = '/';
spyOn(router, 'navigateByUrl');
@@ -178,5 +178,5 @@ describe('AuthGuardService', () => {
expect(authService.setRedirect).toHaveBeenCalledWith({
provider: 'ALL', url: '/'
});
}));
});
});

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { fakeAsync, TestBed } from '@angular/core/testing';
import { setupTestBed, AlfrescoApiService, IdentityGroupService, IdentityGroupSearchParam } from '@alfresco/adf-core';
import { HttpErrorResponse } from '@angular/common/http';
import { throwError, of } from 'rxjs';
@@ -46,7 +46,7 @@ describe('IdentityGroupService', () => {
]
});
beforeEach(async(() => {
beforeEach(fakeAsync(() => {
service = TestBed.inject(IdentityGroupService);
apiService = TestBed.inject(AlfrescoApiService);
}));

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 { By, DomSanitizer } from '@angular/platform-browser';
import { AuthenticationService, ContentService } from '../../services';
import { InitialUsernamePipe } from '../../pipes';
@@ -94,7 +94,7 @@ describe('User info component', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(UserInfoComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
@@ -108,7 +108,7 @@ describe('User info component', () => {
spyOn(window, 'requestAnimationFrame').and.returnValue(1);
spyOn(bpmUserService, 'getCurrentUserProfileImage').and.returnValue('app/rest/admin/profile-picture');
spyOn(contentService, 'getContentUrl').and.returnValue('alfresco-logo.svg');
}));
});
afterEach(() => {
fixture.destroy();
@@ -209,13 +209,13 @@ describe('User info component', () => {
describe('and has image', () => {
beforeEach(async(() => {
beforeEach(() => {
isOauthStub.and.returnValue(false);
isEcmLoggedInStub.and.returnValue(true);
isLoggedInStub.and.returnValue(true);
getCurrenEcmtUserInfoStub.and.returnValue(of(fakeEcmUser));
fixture.detectChanges();
}));
});
it('should get the ecm current user image from the service', async () => {
await fixture.whenStable();
@@ -316,15 +316,15 @@ describe('User info component', () => {
describe('when user is logged on bpm', () => {
let getCurrentUserInfoStub;
let getCurrentUserInfoStub: jasmine.Spy;
beforeEach(async(() => {
beforeEach(() => {
isOauthStub.and.returnValue(false);
isBpmLoggedInStub.and.returnValue(true);
isLoggedInStub.and.returnValue(true);
isEcmLoggedInStub.and.returnValue(false);
getCurrentUserInfoStub = spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmUser));
}));
});
it('should fetch bpm userInfo', (done) => {
getCurrentUserInfoStub.and.returnValue(of(fakeBpmUser));
@@ -427,7 +427,7 @@ describe('User info component', () => {
describe('when user is logged on bpm and ecm', () => {
beforeEach(async(() => {
beforeEach(() => {
isOauthStub.and.returnValue(false);
isEcmLoggedInStub.and.returnValue(true);
isBpmLoggedInStub.and.returnValue(true);
@@ -435,7 +435,7 @@ describe('User info component', () => {
getCurrenEcmtUserInfoStub.and.returnValue(of(fakeEcmUser));
spyOn(bpmUserService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmUser));
}));
});
it('should able to fetch ecm userInfo', (done) => {
fixture.detectChanges();
@@ -537,14 +537,14 @@ describe('User info component', () => {
describe('when identity user is logged in', () => {
let getCurrentUserInfoStub;
let getCurrentUserInfoStub: jasmine.Spy;
beforeEach(async(() => {
beforeEach(() => {
isOauthStub.and.returnValue(true);
isLoggedInStub.and.returnValue(true);
isEcmLoggedInStub.and.returnValue(false);
getCurrentUserInfoStub = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
}));
});
it('should show the identity user initials if is not ecm user', async () => {
fixture.detectChanges();

View File

@@ -16,7 +16,7 @@
*/
import { DomSanitizer } from '@angular/platform-browser';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PdfThumbComponent } from './pdf-viewer-thumb.component';
import { setupTestBed } from '../../testing/setup-test-bed';
import { CoreTestingModule } from '../../testing/core.testing.module';
@@ -52,10 +52,10 @@ describe('PdfThumbComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(PdfThumbComponent);
component = fixture.componentInstance;
}));
});
it('should have resolve image data', (done) => {
component.page = page;

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 { By } from '@angular/platform-browser';
import { PdfThumbListComponent } from './pdf-viewer-thumbnails.component';
import { setupTestBed } from '../../testing/setup-test-bed';
@@ -69,7 +69,7 @@ describe('PdfThumbListComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(PdfThumbListComponent);
component = fixture.componentInstance;
component.pdfViewer = viewerMock;
@@ -80,7 +80,7 @@ describe('PdfThumbListComponent', () => {
fixture.nativeElement.style.overflow = 'scroll';
fixture.debugElement.query(By.css('.adf-pdf-thumbnails__content'))
.nativeElement.style.height = '2000px';
}));
});
it('should render initial rage of items', () => {
fixture.nativeElement.scrollTop = 0;

View File

@@ -38,7 +38,7 @@ export class TxtViewerComponent implements OnChanges {
constructor(private http: HttpClient, private appConfigService: AppConfigService) {
}
ngOnChanges(changes: SimpleChanges): Promise<any> {
ngOnChanges(changes: SimpleChanges): Promise<void> {
const blobFile = changes['blobFile'];
if (blobFile && blobFile.currentValue) {
@@ -57,7 +57,7 @@ export class TxtViewerComponent implements OnChanges {
return Promise.resolve();
}
private getUrlContent(url: string): Promise<any> {
private getUrlContent(url: string): Promise<void> {
const withCredentialsMode = this.appConfigService.get<boolean>('auth.withCredentials', false);
return new Promise((resolve, reject) => {
@@ -70,7 +70,7 @@ export class TxtViewerComponent implements OnChanges {
});
}
private readBlob(blob: Blob): Promise<any> {
private readBlob(blob: Blob): Promise<void> {
return new Promise((resolve, reject) => {
const reader = new FileReader();

View File

@@ -18,7 +18,7 @@
import { Location } from '@angular/common';
import { SpyLocation } from '@angular/common/testing';
import { ElementRef } from '@angular/core';
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { ViewerComponent } from '../components/viewer.component';
import { ViewerExtensionDirective } from './viewer-extension.directive';
import { setupTestBed } from '../../testing/setup-test-bed';
@@ -47,10 +47,10 @@ describe('ExtensionViewerDirective', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
extensionViewerDirective = TestBed.inject(ViewerExtensionDirective);
extensionViewerDirective.templateModel = {template: '', isVisible: false};
}));
});
it('is defined', () => {
expect(extensionViewerDirective).toBeDefined();

View File

@@ -24,7 +24,7 @@ import {
SimpleChange,
ComponentFactoryResolver
} 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 { DynamicExtensionComponent } from './dynamic.component';
import { ComponentRegisterService } from '../../services/component-register.service';
@@ -50,7 +50,7 @@ describe('DynamicExtensionComponent', () => {
let component: DynamicExtensionComponent;
let componentFactoryResolver: ComponentFactoryResolver;
beforeEach(async(() => {
beforeEach(() => {
componentRegister = new ComponentRegisterService();
componentRegister.setComponents({ 'test-component': TestComponent });
@@ -61,7 +61,7 @@ describe('DynamicExtensionComponent', () => {
});
TestBed.compileComponents();
}));
});
describe('Sub-component creation', () => {

View File

@@ -17,7 +17,7 @@
import { Component, DebugElement, SimpleChange, NgModule, Injector, ComponentFactoryResolver, ViewChild } from '@angular/core';
import { By } from '@angular/platform-browser';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of, throwError } from 'rxjs';
import {
CoreModule,
@@ -118,7 +118,7 @@ describe('FormCloudComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
const apiService = TestBed.inject(AlfrescoApiService);
spyOn(apiService, 'getInstance').and.returnValue(mockOauth2Auth);
@@ -133,7 +133,7 @@ describe('FormCloudComponent', () => {
fixture = TestBed.createComponent(FormCloudComponent);
formComponent = fixture.componentInstance;
fixture.detectChanges();
}));
});
it('should register custom [upload] widget', () => {
const widget = buildWidget('upload', fixture.componentRef.injector);
@@ -1154,7 +1154,7 @@ describe('retrieve metadata on submit', () => {
}
};
beforeEach(async(() => {
beforeEach(() => {
const apiService = TestBed.inject(AlfrescoApiService);
spyOn(apiService, 'getInstance').and.returnValue(mockOauth2Auth);
@@ -1164,7 +1164,7 @@ describe('retrieve metadata on submit', () => {
formComponent = fixture.componentInstance;
formComponent.form = formComponent.parseForm(fakeMetadataForm);
fixture.detectChanges();
}));
});
it('should set values when updateFormValuesRequested is updated', async () => {
formComponent.form.values['pfx_property_three'] = {};

View File

@@ -405,7 +405,7 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(widget.rootNodeId).toEqual('-my-');
});
it('should return the application name in case -appname- placeholder is present', async() => {
it('should return the application name in case -appname- placeholder is present', () => {
appConfigService.config = Object.assign(appConfigService.config, {
'alfresco-deployed-apps': [
{
@@ -417,7 +417,7 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(widget.replaceAppNameAliasWithValue('/myfiles/-appname-/folder')).toBe('/myfiles/fakeapp/folder');
});
it('should return the same value in case -appname- placeholder is NOT present', async() => {
it('should return the same value in case -appname- placeholder is NOT present', () => {
expect(widget.replaceAppNameAliasWithValue('/myfiles/fakepath/folder')).toBe('/myfiles/fakepath/folder');
});

View File

@@ -30,7 +30,7 @@ describe('ProcessNameCloudPipe', () => {
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}`;

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { setupTestBed, IdentityUserService } from '@alfresco/adf-core';
import { of } from 'rxjs';
import { ProcessFilterCloudService } from './process-filter-cloud.service';
@@ -50,7 +50,7 @@ describe('ProcessFilterCloudService', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
service = TestBed.inject(ProcessFilterCloudService);
const preferenceCloudService = service.preferenceService;
@@ -61,7 +61,7 @@ describe('ProcessFilterCloudService', () => {
getPreferenceByKeySpy = spyOn(preferenceCloudService, 'getPreferenceByKey').and.returnValue(of(fakeProcessCloudFilters));
getPreferencesSpy = spyOn(preferenceCloudService, 'getPreferences').and.returnValue(of(fakeProcessCloudFilterEntries));
getCurrentUserInfoSpy = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
}));
});
it('should create processfilter key by using appName and the username', (done) => {
service.getProcessFilters('mock-appName').subscribe((res: any) => {

View File

@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { fakeAsync, TestBed } from '@angular/core/testing';
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { ProcessListCloudService } from './process-list-cloud.service';
import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model';
@@ -56,13 +56,13 @@ describe('ProcessListCloudService', () => {
]
});
beforeEach(async(() => {
beforeEach(fakeAsync(() => {
alfrescoApiService = TestBed.inject(AlfrescoApiService);
service = TestBed.inject(ProcessListCloudService);
}));
it('should append to the call all the parameters', (done) => {
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
const processRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as ProcessQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
service.getProcessByRequest(processRequest).subscribe((res) => {
expect(res).toBeDefined();
@@ -75,7 +75,7 @@ describe('ProcessListCloudService', () => {
});
it('should concat the app name to the request url', (done) => {
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
const processRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as ProcessQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
service.getProcessByRequest(processRequest).subscribe((requestUrl) => {
expect(requestUrl).toBeDefined();
@@ -86,10 +86,10 @@ describe('ProcessListCloudService', () => {
});
it('should concat the sorting to append as parameters', (done) => {
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> {
const processRequest = {
appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }]
};
} as ProcessQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
service.getProcessByRequest(processRequest).subscribe((res) => {
expect(res).toBeDefined();
@@ -100,7 +100,7 @@ describe('ProcessListCloudService', () => {
});
it('should return an error when app name is not specified', (done) => {
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: null };
const processRequest = { appName: null } as ProcessQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
service.getProcessByRequest(processRequest).subscribe(
() => { },

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { TestBed, async } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { AlfrescoApiService, setupTestBed } from '@alfresco/adf-core';
import { ProcessServiceCloudTestingModule } from '../testing/process-service-cloud.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -60,7 +60,7 @@ describe('NotificationCloudService', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
service = TestBed.inject(NotificationCloudService);
apollo = TestBed.inject(Apollo);
apiService = TestBed.inject(AlfrescoApiService);
@@ -69,7 +69,7 @@ describe('NotificationCloudService', () => {
service.appsListening = [];
apolloCreateSpy = spyOn(apollo, 'createNamed');
apolloSubscribeSpy = spyOn(apollo, 'use').and.returnValue(useMock);
}));
});
it('should not create more than one websocket per app if it was already created', () => {
service.makeGQLQuery('myAppName', queryMock);

View File

@@ -15,8 +15,7 @@
* limitations under the License.
*/
import { TestBed, async } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { UserPreferenceCloudService } from './user-preference-cloud.service';
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { mockPreferences, getMockPreference, createMockPreference, updateMockPreference } from '../mock/user-preference.mock';
@@ -63,11 +62,11 @@ describe('PreferenceService', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
service = TestBed.inject(UserPreferenceCloudService);
alfrescoApiMock = TestBed.inject(AlfrescoApiService);
getInstanceSpy = spyOn(alfrescoApiMock, 'getInstance').and.returnValue(apiMock(mockPreferences));
}));
});
it('should return the preferences', (done) => {
service.getPreferences('mock-app-name').subscribe((res: any) => {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { ServiceTaskListCloudService } from './service-task-list-cloud.service';
import { ServiceTaskQueryCloudRequestModel } from '../models/service-task-cloud.model';
@@ -59,10 +59,10 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
alfrescoApiService = TestBed.inject(AlfrescoApiService);
service = TestBed.inject(ServiceTaskListCloudService);
}));
});
it('should append to the call all the parameters', (done) => {
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };

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();