mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
workarounds for jasmine.ajax in unit tests
This commit is contained in:
committed by
Anton Ramanovich
parent
4d84f665ce
commit
880c670593
@@ -18,6 +18,7 @@
|
||||
import { DocumentListService } from './document-list.service';
|
||||
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -68,7 +69,11 @@ describe('DocumentListService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule]
|
||||
imports: [ContentTestingModule],
|
||||
providers: [
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(DocumentListService);
|
||||
jasmine.Ajax.install();
|
||||
|
@@ -31,7 +31,7 @@ export class AlfrescoApiService {
|
||||
protected appConfig = inject(AppConfigService);
|
||||
protected storageService = inject(StorageService);
|
||||
protected alfrescoApiFactory = inject<AlfrescoApiFactory>(ALFRESCO_API_FACTORY, { optional: true });
|
||||
protected adfHttpClient = inject(AdfHttpClient);
|
||||
protected adfHttpClient = inject(AdfHttpClient, { optional: true });
|
||||
|
||||
alfrescoApiInitialized: ReplaySubject<boolean> = new ReplaySubject(1);
|
||||
|
||||
|
@@ -71,12 +71,23 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
ee(this);
|
||||
}
|
||||
|
||||
/** @deprecated not used anywhere */
|
||||
/**
|
||||
* Update the default security options
|
||||
*
|
||||
* @param options security options
|
||||
* @deprecated not used anywhere
|
||||
*/
|
||||
setDefaultSecurityOption(options: any) {
|
||||
this.defaultSecurityOptions = this.merge(this.defaultSecurityOptions, options);
|
||||
}
|
||||
|
||||
/** @deprecated not used anywhere */
|
||||
/**
|
||||
* Merge objects
|
||||
*
|
||||
* @param objects objects to merge
|
||||
* @deprecated not used anywhere
|
||||
* @returns merged object
|
||||
*/
|
||||
merge(...objects): any {
|
||||
const result = {};
|
||||
|
||||
@@ -228,6 +239,7 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
)
|
||||
.toPromise();
|
||||
|
||||
/* eslint-disable @typescript-eslint/space-before-function-paren */
|
||||
(promise as any).abort = function () {
|
||||
eventEmitter.emit('abort');
|
||||
abort$.next();
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ObjectUtils } from '../common/utils/object-utils';
|
||||
import { Observable, ReplaySubject } from 'rxjs';
|
||||
import { map, distinctUntilChanged, take } from 'rxjs/operators';
|
||||
@@ -77,17 +77,14 @@ export class AppConfigService {
|
||||
};
|
||||
|
||||
status: Status = Status.INIT;
|
||||
protected onLoadSubject: ReplaySubject<any>;
|
||||
onLoad: Observable<any>;
|
||||
protected readonly onLoadSubject = new ReplaySubject<any>();
|
||||
onLoad = this.onLoadSubject.asObservable();
|
||||
|
||||
get isLoaded() {
|
||||
return this.status === Status.LOADED;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.onLoadSubject = new ReplaySubject();
|
||||
this.onLoad = this.onLoadSubject.asObservable();
|
||||
|
||||
this.extensionService.setup$.subscribe((config) => {
|
||||
this.onExtensionsLoaded(config);
|
||||
});
|
||||
|
@@ -15,15 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { StorageService } from '../common/services/storage.service';
|
||||
import { AppConfigService, AppConfigValues } from './app-config.service';
|
||||
|
||||
@Injectable()
|
||||
export class DebugAppConfigService extends AppConfigService {
|
||||
constructor(private storage: StorageService) {
|
||||
super();
|
||||
}
|
||||
private storage = inject(StorageService);
|
||||
|
||||
get<T>(key: string, defaultValue?: T): T {
|
||||
if (key === AppConfigValues.OAUTHCONFIG) {
|
||||
|
@@ -19,6 +19,7 @@ import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CreateProcessAttachmentComponent } from './create-process-attachment.component';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -48,7 +49,11 @@ describe('CreateProcessAttachmentComponent', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CreateProcessAttachmentComponent],
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(CreateProcessAttachmentComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -20,6 +20,7 @@ import { FormModel } from '@alfresco/adf-core';
|
||||
import { EcmModelService } from './ecm-model.service';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -29,7 +30,11 @@ describe('EcmModelService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(EcmModelService);
|
||||
jasmine.Ajax.install();
|
||||
|
@@ -18,6 +18,7 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ProcessContentService } from './process-content.service';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -66,7 +67,11 @@ describe('ProcessContentService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(ProcessContentService);
|
||||
});
|
||||
|
@@ -23,6 +23,7 @@ import { of } from 'rxjs';
|
||||
import { ContentWidgetComponent } from './content.widget';
|
||||
import { ProcessContentService } from '../../services/process-content.service';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -61,7 +62,11 @@ describe('ContentWidgetComponent', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentWidgetComponent],
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
downloadService = TestBed.inject(DownloadService);
|
||||
processContentService = TestBed.inject(ProcessContentService);
|
||||
|
@@ -19,6 +19,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { PeopleSearchComponent } from './people-search.component';
|
||||
import { LightUserRepresentation } from '@alfresco/js-api';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
const fakeUser: LightUserRepresentation = {
|
||||
id: 1,
|
||||
@@ -43,7 +44,11 @@ describe('PeopleSearchComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [PeopleSearchComponent]
|
||||
imports: [PeopleSearchComponent],
|
||||
providers: [
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(PeopleSearchComponent);
|
||||
peopleSearchComponent = fixture.componentInstance;
|
||||
|
@@ -18,8 +18,9 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PeopleComponent } from './people.component';
|
||||
import { LightUserRepresentation } from '@alfresco/js-api';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { PeopleProcessService } from '../../../services/people-process.service';
|
||||
import { PeopleProcessService } from '@alfresco/adf-process-services';
|
||||
|
||||
const fakeUser: LightUserRepresentation = {
|
||||
id: 0,
|
||||
@@ -44,7 +45,11 @@ describe('PeopleComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [PeopleComponent]
|
||||
imports: [PeopleComponent],
|
||||
providers: [
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(PeopleComponent);
|
||||
peopleProcessService = fixture.debugElement.injector.get(PeopleProcessService);
|
||||
|
@@ -20,6 +20,7 @@ import { ProcessFilterService } from './process-filter.service';
|
||||
import { ProcessInstanceFilterRepresentation, UserProcessInstanceFilterRepresentation } from '@alfresco/js-api';
|
||||
import { of } from 'rxjs';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -49,7 +50,12 @@ describe('Process filter', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
imports: [],
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(ProcessFilterService);
|
||||
});
|
||||
|
@@ -19,6 +19,7 @@ import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { PeopleProcessService } from './people-process.service';
|
||||
import { LightUserRepresentation } from '@alfresco/js-api';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -45,7 +46,12 @@ describe('PeopleProcessService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
imports: [],
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(PeopleProcessService);
|
||||
});
|
||||
|
@@ -41,6 +41,7 @@ import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
|
||||
import { MatMenuItemHarness } from '@angular/material/menu/testing';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -109,7 +110,9 @@ describe('TaskListComponent', () => {
|
||||
providers: [
|
||||
TaskListService,
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
appConfig = TestBed.inject(AppConfigService);
|
||||
|
Reference in New Issue
Block a user