mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
workarounds for jasmine.ajax in unit tests
This commit is contained in:
parent
d72a3d2096
commit
40a9b37f63
@ -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';
|
||||
@ -76,17 +76,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);
|
||||
|
||||
/** @override */
|
||||
get<T>(key: string, defaultValue?: T): T {
|
||||
|
@ -20,6 +20,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CreateProcessAttachmentComponent } from './create-process-attachment.component';
|
||||
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@ -49,7 +50,11 @@ describe('CreateProcessAttachmentComponent', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ProcessTestingModule, 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, CoreTestingModule } 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: [CoreTestingModule],
|
||||
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();
|
||||
|
@ -20,6 +20,7 @@ import { of } from 'rxjs';
|
||||
import { ProcessContentService } from './process-content.service';
|
||||
import { CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@ -68,7 +69,11 @@ describe('ProcessContentService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreTestingModule],
|
||||
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: [CoreTestingModule, 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);
|
||||
|
@ -20,6 +20,7 @@ import { of } from 'rxjs';
|
||||
import { PeopleSearchComponent } from './people-search.component';
|
||||
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
||||
import { LightUserRepresentation } from '@alfresco/js-api';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
const fakeUser: LightUserRepresentation = {
|
||||
id: 1,
|
||||
@ -44,7 +45,11 @@ describe('PeopleSearchComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ProcessTestingModule, PeopleSearchComponent]
|
||||
imports: [ProcessTestingModule, 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;
|
||||
|
@ -19,8 +19,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PeopleComponent } from './people.component';
|
||||
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
||||
import { LightUserRepresentation } from '@alfresco/js-api';
|
||||
import { PeopleProcessService } from '@alfresco/adf-process-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { PeopleProcessService } from '@alfresco/adf-process-services';
|
||||
|
||||
const fakeUser: LightUserRepresentation = {
|
||||
id: 0,
|
||||
@ -45,7 +46,11 @@ describe('PeopleComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ProcessTestingModule, PeopleComponent]
|
||||
imports: [ProcessTestingModule, 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);
|
||||
|
@ -21,6 +21,7 @@ import { CoreTestingModule } from '@alfresco/adf-core';
|
||||
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;
|
||||
|
||||
@ -51,7 +52,11 @@ describe('Process filter', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreTestingModule],
|
||||
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(ProcessFilterService);
|
||||
});
|
||||
|
@ -20,6 +20,7 @@ import { PeopleProcessService } from './people-process.service';
|
||||
import { CoreTestingModule } from '@alfresco/adf-core';
|
||||
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;
|
||||
|
||||
@ -47,7 +48,11 @@ describe('PeopleProcessService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreTestingModule],
|
||||
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(PeopleProcessService);
|
||||
});
|
||||
|
@ -44,6 +44,7 @@ import { MatMenuItemHarness } from '@angular/material/menu/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@ -112,7 +113,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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user