mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
111731: Fixed tests not mocking SearchConfigurationService
This commit is contained in:
@@ -1,38 +1,23 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
Component,
|
||||
NO_ERRORS_SCHEMA,
|
||||
} from '@angular/core';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import {
|
||||
ComponentFixture,
|
||||
TestBed,
|
||||
waitForAsync,
|
||||
} from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { provideMockStore } from '@ngrx/store/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import {
|
||||
cold,
|
||||
getTestScheduler,
|
||||
hot,
|
||||
} from 'jasmine-marbles';
|
||||
import {
|
||||
of as observableOf,
|
||||
of,
|
||||
} from 'rxjs';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
||||
import { APP_DATA_SERVICES_MAP } from '../../../../config/app-config.interface';
|
||||
import { BitstreamFormatDataService } from '../../../core/data/bitstream-format-data.service';
|
||||
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
|
||||
import { GroupDataService } from '../../../core/eperson/group-data.service';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
|
||||
import { BitstreamFormatSupportLevel } from '../../../core/shared/bitstream-format-support-level';
|
||||
import { XSRFService } from '../../../core/xsrf/xsrf.service';
|
||||
import { HostWindowService } from '../../../shared/host-window.service';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
|
||||
import {
|
||||
@@ -41,7 +26,6 @@ import {
|
||||
createSuccessfulRemoteDataObject,
|
||||
createSuccessfulRemoteDataObject$,
|
||||
} from '../../../shared/remote-data.utils';
|
||||
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service.stub';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
||||
@@ -52,7 +36,6 @@ describe('BitstreamFormatsComponent', () => {
|
||||
let comp: BitstreamFormatsComponent;
|
||||
let fixture: ComponentFixture<BitstreamFormatsComponent>;
|
||||
let bitstreamFormatService;
|
||||
let scheduler: TestScheduler;
|
||||
let notificationsServiceStub;
|
||||
let paginationService;
|
||||
|
||||
@@ -107,8 +90,6 @@ describe('BitstreamFormatsComponent', () => {
|
||||
const initAsync = () => {
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||
@@ -120,33 +101,28 @@ describe('BitstreamFormatsComponent', () => {
|
||||
clearBitStreamFormatRequests: observableOf('cleared'),
|
||||
});
|
||||
|
||||
const groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||
getGroupRegistryRouterLink: '',
|
||||
getUUIDFromString: '',
|
||||
});
|
||||
|
||||
|
||||
const configurationDataService = jasmine.createSpyObj('ConfigurationDataService', {
|
||||
findByPropertyName: of({ payload: { value: 'test' } }),
|
||||
});
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
imports: [
|
||||
BitstreamFormatsComponent,
|
||||
EnumKeysPipe,
|
||||
RouterModule.forRoot([]),
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
providers: [
|
||||
provideMockStore(),
|
||||
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
|
||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||
{ provide: PaginationService, useValue: paginationService },
|
||||
{ provide: GroupDataService, useValue: groupDataService },
|
||||
{ provide: ConfigurationDataService, useValue: configurationDataService },
|
||||
{ provide: XSRFService, useValue: {} },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
}).overrideComponent(BitstreamFormatsComponent, {
|
||||
remove: {
|
||||
imports: [
|
||||
PaginationComponent,
|
||||
],
|
||||
},
|
||||
}).compileComponents();
|
||||
};
|
||||
|
||||
@@ -251,8 +227,6 @@ describe('BitstreamFormatsComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||
@@ -264,37 +238,26 @@ describe('BitstreamFormatsComponent', () => {
|
||||
clearBitStreamFormatRequests: observableOf('cleared'),
|
||||
});
|
||||
|
||||
const groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||
getGroupRegistryRouterLink: '',
|
||||
getUUIDFromString: '',
|
||||
});
|
||||
|
||||
const configurationDataService = jasmine.createSpyObj('ConfigurationDataService', {
|
||||
findByPropertyName: of({ payload: { value: 'test' } }),
|
||||
});
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule,
|
||||
BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
BitstreamFormatsComponent,
|
||||
EnumKeysPipe,
|
||||
PaginationComponent,
|
||||
RouterModule.forRoot([]),
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
providers: [
|
||||
provideMockStore(),
|
||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||
{ provide: PaginationService, useValue: paginationService },
|
||||
{ provide: GroupDataService, useValue: groupDataService },
|
||||
{ provide: ConfigurationDataService, useValue: configurationDataService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
})
|
||||
.overrideComponent(BitstreamFormatsComponent, {
|
||||
remove: { imports: [PaginationComponent] },
|
||||
add: { imports: [TestPaginationComponent] },
|
||||
})
|
||||
.compileComponents();
|
||||
},
|
||||
@@ -321,8 +284,6 @@ describe('BitstreamFormatsComponent', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||
findAll: observableOf(mockFormatsRD),
|
||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||
@@ -334,35 +295,24 @@ describe('BitstreamFormatsComponent', () => {
|
||||
clearBitStreamFormatRequests: observableOf('cleared'),
|
||||
});
|
||||
|
||||
const groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||
getGroupRegistryRouterLink: '',
|
||||
getUUIDFromString: '',
|
||||
});
|
||||
|
||||
const configurationDataService = jasmine.createSpyObj('ConfigurationDataService', {
|
||||
findByPropertyName: of({ payload: { value: 'test' } }),
|
||||
});
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
||||
imports: [
|
||||
BitstreamFormatsComponent,
|
||||
EnumKeysPipe,
|
||||
RouterModule.forRoot([]),
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
providers: [
|
||||
provideMockStore(),
|
||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||
{ provide: PaginationService, useValue: paginationService },
|
||||
{ provide: PaginationService, useValue: paginationService },
|
||||
{ provide: GroupDataService, useValue: groupDataService },
|
||||
{ provide: ConfigurationDataService, useValue: configurationDataService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
})
|
||||
.overrideComponent(BitstreamFormatsComponent, {
|
||||
remove: { imports: [PaginationComponent] },
|
||||
add: { imports: [TestPaginationComponent] },
|
||||
})
|
||||
.compileComponents();
|
||||
},
|
||||
@@ -384,12 +334,3 @@ describe('BitstreamFormatsComponent', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@Component({
|
||||
exportAs: 'paginationComponent',
|
||||
selector: 'ds-pagination',
|
||||
template: ``,
|
||||
standalone: true,
|
||||
})
|
||||
export class TestPaginationComponent {
|
||||
}
|
||||
|
Reference in New Issue
Block a user