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:
@@ -22,10 +22,7 @@ import {
|
|||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { provideMockStore } from '@ngrx/store/testing';
|
import { provideMockStore } from '@ngrx/store/testing';
|
||||||
import {
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
TranslateLoader,
|
|
||||||
TranslateModule,
|
|
||||||
} from '@ngx-translate/core';
|
|
||||||
import {
|
import {
|
||||||
Observable,
|
Observable,
|
||||||
of as observableOf,
|
of as observableOf,
|
||||||
@@ -59,6 +56,7 @@ import {
|
|||||||
} from '../../shared/mocks/dso-name.service.mock';
|
} from '../../shared/mocks/dso-name.service.mock';
|
||||||
import { RouterMock } from '../../shared/mocks/router.mock';
|
import { RouterMock } from '../../shared/mocks/router.mock';
|
||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
import { PaginationComponent } from '../../shared/pagination/pagination.component';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
|
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
|
||||||
import {
|
import {
|
||||||
@@ -72,7 +70,6 @@ import {
|
|||||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
||||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||||
import { routeServiceStub } from '../../shared/testing/route-service.stub';
|
import { routeServiceStub } from '../../shared/testing/route-service.stub';
|
||||||
import { TranslateLoaderMock } from '../../shared/testing/translate-loader.mock';
|
|
||||||
import { GroupsRegistryComponent } from './groups-registry.component';
|
import { GroupsRegistryComponent } from './groups-registry.component';
|
||||||
|
|
||||||
describe('GroupsRegistryComponent', () => {
|
describe('GroupsRegistryComponent', () => {
|
||||||
@@ -209,12 +206,9 @@ describe('GroupsRegistryComponent', () => {
|
|||||||
paginationService = new PaginationServiceStub();
|
paginationService = new PaginationServiceStub();
|
||||||
return TestBed.configureTestingModule({
|
return TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot(),
|
||||||
loader: {
|
GroupsRegistryComponent,
|
||||||
provide: TranslateLoader,
|
],
|
||||||
useClass: TranslateLoaderMock,
|
|
||||||
},
|
|
||||||
}), GroupsRegistryComponent],
|
|
||||||
providers: [GroupsRegistryComponent,
|
providers: [GroupsRegistryComponent,
|
||||||
{ provide: DSONameService, useValue: new DSONameServiceMock() },
|
{ provide: DSONameService, useValue: new DSONameServiceMock() },
|
||||||
{ provide: EPersonDataService, useValue: ePersonDataServiceStub },
|
{ provide: EPersonDataService, useValue: ePersonDataServiceStub },
|
||||||
@@ -232,6 +226,12 @@ describe('GroupsRegistryComponent', () => {
|
|||||||
provideMockStore(),
|
provideMockStore(),
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA],
|
schemas: [NO_ERRORS_SCHEMA],
|
||||||
|
}).overrideComponent(GroupsRegistryComponent, {
|
||||||
|
remove: {
|
||||||
|
imports: [
|
||||||
|
PaginationComponent,
|
||||||
|
],
|
||||||
|
},
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@@ -14,10 +14,7 @@ import {
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
UntypedFormBuilder,
|
UntypedFormBuilder,
|
||||||
} from '@angular/forms';
|
} from '@angular/forms';
|
||||||
import {
|
import { RouterLink } from '@angular/router';
|
||||||
Router,
|
|
||||||
RouterLink,
|
|
||||||
} from '@angular/router';
|
|
||||||
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import {
|
import {
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
@@ -149,7 +146,6 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
|
|||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
private formBuilder: UntypedFormBuilder,
|
private formBuilder: UntypedFormBuilder,
|
||||||
protected routeService: RouteService,
|
protected routeService: RouteService,
|
||||||
private router: Router,
|
|
||||||
private authorizationService: AuthorizationDataService,
|
private authorizationService: AuthorizationDataService,
|
||||||
private paginationService: PaginationService,
|
private paginationService: PaginationService,
|
||||||
public requestService: RequestService,
|
public requestService: RequestService,
|
||||||
|
@@ -2,57 +2,34 @@ import {
|
|||||||
ComponentFixture,
|
ComponentFixture,
|
||||||
TestBed,
|
TestBed,
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { provideMockStore } from '@ngrx/store/testing';
|
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
import { APP_DATA_SERVICES_MAP } from '../../../../../config/app-config.interface';
|
|
||||||
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
|
||||||
import { RequestService } from '../../../../core/data/request.service';
|
|
||||||
import { RouteService } from '../../../../core/services/route.service';
|
|
||||||
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
|
|
||||||
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-configuration.service';
|
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-configuration.service';
|
||||||
import { MockActivatedRoute } from '../../../../shared/mocks/active-router.mock';
|
import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service.stub';
|
||||||
import { getMockRemoteDataBuildService } from '../../../../shared/mocks/remote-data-build.service.mock';
|
|
||||||
import { routeServiceStub } from '../../../../shared/testing/route-service.stub';
|
|
||||||
import { AdminNotifyLogsResultComponent } from '../admin-notify-logs-result/admin-notify-logs-result.component';
|
import { AdminNotifyLogsResultComponent } from '../admin-notify-logs-result/admin-notify-logs-result.component';
|
||||||
import { AdminNotifyIncomingComponent } from './admin-notify-incoming.component';
|
import { AdminNotifyIncomingComponent } from './admin-notify-incoming.component';
|
||||||
|
|
||||||
describe('AdminNotifyIncomingComponent', () => {
|
describe('AdminNotifyIncomingComponent', () => {
|
||||||
let component: AdminNotifyIncomingComponent;
|
let component: AdminNotifyIncomingComponent;
|
||||||
let fixture: ComponentFixture<AdminNotifyIncomingComponent>;
|
let fixture: ComponentFixture<AdminNotifyIncomingComponent>;
|
||||||
let halService: HALEndpointService;
|
|
||||||
let requestService: RequestService;
|
|
||||||
let rdbService: RemoteDataBuildService;
|
|
||||||
|
|
||||||
|
|
||||||
|
let searchConfigurationService: SearchConfigurationServiceStub;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
rdbService = getMockRemoteDataBuildService();
|
searchConfigurationService = new SearchConfigurationServiceStub();
|
||||||
halService = jasmine.createSpyObj('halService', {
|
|
||||||
'getRootHref': '/api',
|
|
||||||
});
|
|
||||||
requestService = jasmine.createSpyObj('requestService', {
|
|
||||||
'generateRequestId': 'client/1234',
|
|
||||||
'send': '',
|
|
||||||
});
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), AdminNotifyIncomingComponent],
|
imports: [
|
||||||
providers: [
|
AdminNotifyIncomingComponent,
|
||||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: SearchConfigurationService },
|
RouterModule.forRoot([]),
|
||||||
{ provide: RouteService, useValue: routeServiceStub },
|
TranslateModule.forRoot(),
|
||||||
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
|
|
||||||
{ provide: HALEndpointService, useValue: halService },
|
|
||||||
{ provide: RequestService, useValue: requestService },
|
|
||||||
{ provide: RemoteDataBuildService, useValue: rdbService },
|
|
||||||
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
|
|
||||||
provideMockStore({}),
|
|
||||||
],
|
],
|
||||||
|
}).overrideProvider(SEARCH_CONFIG_SERVICE, {
|
||||||
|
useValue: searchConfigurationService,
|
||||||
}).overrideComponent(AdminNotifyIncomingComponent, {
|
}).overrideComponent(AdminNotifyIncomingComponent, {
|
||||||
remove: { imports: [AdminNotifyLogsResultComponent] },
|
remove: { imports: [AdminNotifyLogsResultComponent] },
|
||||||
})
|
}).compileComponents();
|
||||||
.compileComponents();
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(AdminNotifyIncomingComponent);
|
fixture = TestBed.createComponent(AdminNotifyIncomingComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
@@ -6,54 +6,41 @@ import {
|
|||||||
ActivatedRoute,
|
ActivatedRoute,
|
||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
import { provideMockStore } from '@ngrx/store/testing';
|
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
import { APP_DATA_SERVICES_MAP } from '../../../../../config/app-config.interface';
|
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-configuration.service';
|
||||||
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
|
||||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
|
||||||
import { RequestService } from '../../../../core/data/request.service';
|
|
||||||
import { RouteService } from '../../../../core/services/route.service';
|
|
||||||
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
|
|
||||||
import { MockActivatedRoute } from '../../../../shared/mocks/active-router.mock';
|
import { MockActivatedRoute } from '../../../../shared/mocks/active-router.mock';
|
||||||
import { SearchLabelsComponent } from '../../../../shared/search/search-labels/search-labels.component';
|
import { SearchLabelsComponent } from '../../../../shared/search/search-labels/search-labels.component';
|
||||||
import { ThemedSearchComponent } from '../../../../shared/search/themed-search.component';
|
import { ThemedSearchComponent } from '../../../../shared/search/themed-search.component';
|
||||||
import { routeServiceStub } from '../../../../shared/testing/route-service.stub';
|
|
||||||
import { RouterStub } from '../../../../shared/testing/router.stub';
|
import { RouterStub } from '../../../../shared/testing/router.stub';
|
||||||
|
import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service.stub';
|
||||||
import { AdminNotifyLogsResultComponent } from './admin-notify-logs-result.component';
|
import { AdminNotifyLogsResultComponent } from './admin-notify-logs-result.component';
|
||||||
|
|
||||||
describe('AdminNotifyLogsResultComponent', () => {
|
describe('AdminNotifyLogsResultComponent', () => {
|
||||||
let component: AdminNotifyLogsResultComponent;
|
let component: AdminNotifyLogsResultComponent;
|
||||||
let fixture: ComponentFixture<AdminNotifyLogsResultComponent>;
|
let fixture: ComponentFixture<AdminNotifyLogsResultComponent>;
|
||||||
let objectCache: ObjectCacheService;
|
|
||||||
let requestService: RequestService;
|
let searchConfigurationService: SearchConfigurationServiceStub;
|
||||||
let halService: HALEndpointService;
|
|
||||||
let rdbService: RemoteDataBuildService;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
searchConfigurationService = new SearchConfigurationServiceStub();
|
||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), AdminNotifyLogsResultComponent],
|
imports: [TranslateModule.forRoot(), AdminNotifyLogsResultComponent],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: RouteService, useValue: routeServiceStub },
|
|
||||||
{ provide: Router, useValue: new RouterStub() },
|
{ provide: Router, useValue: new RouterStub() },
|
||||||
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
|
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
|
||||||
{ provide: HALEndpointService, useValue: halService },
|
|
||||||
{ provide: ObjectCacheService, useValue: objectCache },
|
|
||||||
{ provide: RequestService, useValue: requestService },
|
|
||||||
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
|
|
||||||
{ provide: RemoteDataBuildService, useValue: rdbService },
|
|
||||||
provideMockStore({}),
|
|
||||||
],
|
],
|
||||||
})
|
}).overrideProvider(SEARCH_CONFIG_SERVICE, {
|
||||||
.overrideComponent(AdminNotifyLogsResultComponent, {
|
useValue: searchConfigurationService,
|
||||||
remove: {
|
}).overrideComponent(AdminNotifyLogsResultComponent, {
|
||||||
imports: [
|
remove: {
|
||||||
SearchLabelsComponent,
|
imports: [
|
||||||
ThemedSearchComponent,
|
SearchLabelsComponent,
|
||||||
],
|
ThemedSearchComponent,
|
||||||
},
|
],
|
||||||
})
|
},
|
||||||
.compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(AdminNotifyLogsResultComponent);
|
fixture = TestBed.createComponent(AdminNotifyLogsResultComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
@@ -3,7 +3,6 @@ import {
|
|||||||
NgIf,
|
NgIf,
|
||||||
} from '@angular/common';
|
} from '@angular/common';
|
||||||
import {
|
import {
|
||||||
ChangeDetectorRef,
|
|
||||||
Component,
|
Component,
|
||||||
Inject,
|
Inject,
|
||||||
Input,
|
Input,
|
||||||
@@ -59,10 +58,11 @@ export class AdminNotifyLogsResultComponent implements OnInit {
|
|||||||
|
|
||||||
protected readonly context = Context.CoarNotify;
|
protected readonly context = Context.CoarNotify;
|
||||||
|
|
||||||
constructor(@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
|
constructor(
|
||||||
private router: Router,
|
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
|
||||||
private route: ActivatedRoute,
|
protected router: Router,
|
||||||
protected cdRef: ChangeDetectorRef) {
|
protected route: ActivatedRoute,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@@ -2,57 +2,34 @@ import {
|
|||||||
ComponentFixture,
|
ComponentFixture,
|
||||||
TestBed,
|
TestBed,
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { provideMockStore } from '@ngrx/store/testing';
|
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
import { APP_DATA_SERVICES_MAP } from '../../../../../config/app-config.interface';
|
|
||||||
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
|
||||||
import { RequestService } from '../../../../core/data/request.service';
|
|
||||||
import { RouteService } from '../../../../core/services/route.service';
|
|
||||||
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
|
|
||||||
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-configuration.service';
|
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-configuration.service';
|
||||||
import { MockActivatedRoute } from '../../../../shared/mocks/active-router.mock';
|
import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service.stub';
|
||||||
import { getMockRemoteDataBuildService } from '../../../../shared/mocks/remote-data-build.service.mock';
|
|
||||||
import { routeServiceStub } from '../../../../shared/testing/route-service.stub';
|
|
||||||
import { AdminNotifyLogsResultComponent } from '../admin-notify-logs-result/admin-notify-logs-result.component';
|
import { AdminNotifyLogsResultComponent } from '../admin-notify-logs-result/admin-notify-logs-result.component';
|
||||||
import { AdminNotifyOutgoingComponent } from './admin-notify-outgoing.component';
|
import { AdminNotifyOutgoingComponent } from './admin-notify-outgoing.component';
|
||||||
|
|
||||||
describe('AdminNotifyOutgoingComponent', () => {
|
describe('AdminNotifyOutgoingComponent', () => {
|
||||||
let component: AdminNotifyOutgoingComponent;
|
let component: AdminNotifyOutgoingComponent;
|
||||||
let fixture: ComponentFixture<AdminNotifyOutgoingComponent>;
|
let fixture: ComponentFixture<AdminNotifyOutgoingComponent>;
|
||||||
let halService: HALEndpointService;
|
|
||||||
let requestService: RequestService;
|
|
||||||
let rdbService: RemoteDataBuildService;
|
|
||||||
|
|
||||||
|
let searchConfigurationService: SearchConfigurationServiceStub;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
rdbService = getMockRemoteDataBuildService();
|
searchConfigurationService = new SearchConfigurationServiceStub();
|
||||||
requestService = jasmine.createSpyObj('requestService', {
|
|
||||||
'generateRequestId': 'client/1234',
|
|
||||||
'send': '',
|
|
||||||
});
|
|
||||||
halService = jasmine.createSpyObj('halService', {
|
|
||||||
'getRootHref': '/api',
|
|
||||||
});
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot()],
|
imports: [
|
||||||
providers: [
|
AdminNotifyOutgoingComponent,
|
||||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: SearchConfigurationService },
|
RouterModule.forRoot([]),
|
||||||
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
|
TranslateModule.forRoot(),
|
||||||
{ provide: RouteService, useValue: routeServiceStub },
|
|
||||||
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
|
|
||||||
{ provide: HALEndpointService, useValue: halService },
|
|
||||||
{ provide: RequestService, useValue: requestService },
|
|
||||||
{ provide: RemoteDataBuildService, useValue: rdbService },
|
|
||||||
provideMockStore({}),
|
|
||||||
],
|
],
|
||||||
})
|
}).overrideProvider(SEARCH_CONFIG_SERVICE, {
|
||||||
.overrideComponent(AdminNotifyOutgoingComponent, {
|
useValue: searchConfigurationService,
|
||||||
remove: { imports: [AdminNotifyLogsResultComponent] },
|
}).overrideComponent(AdminNotifyOutgoingComponent, {
|
||||||
})
|
remove: { imports: [AdminNotifyLogsResultComponent] },
|
||||||
.compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(AdminNotifyOutgoingComponent);
|
fixture = TestBed.createComponent(AdminNotifyOutgoingComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
@@ -1,29 +1,19 @@
|
|||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
ComponentFixture,
|
ComponentFixture,
|
||||||
TestBed,
|
TestBed,
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { cold } from 'jasmine-marbles';
|
|
||||||
import {
|
import {
|
||||||
of as observableOf,
|
of as observableOf,
|
||||||
of,
|
of,
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
|
|
||||||
import { APP_DATA_SERVICES_MAP } from '../../../../config/app-config.interface';
|
|
||||||
import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service';
|
|
||||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
|
||||||
import { RequestService } from '../../../core/data/request.service';
|
|
||||||
import { RouteService } from '../../../core/services/route.service';
|
|
||||||
import { ConfigurationProperty } from '../../../core/shared/configuration-property.model';
|
|
||||||
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service';
|
|
||||||
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
||||||
import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-configuration.service';
|
import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-configuration.service';
|
||||||
import { routeServiceStub } from '../../../shared/testing/route-service.stub';
|
|
||||||
import { RouterStub } from '../../../shared/testing/router.stub';
|
|
||||||
import { TruncatableComponent } from '../../../shared/truncatable/truncatable.component';
|
import { TruncatableComponent } from '../../../shared/truncatable/truncatable.component';
|
||||||
import { TruncatablePartComponent } from '../../../shared/truncatable/truncatable-part/truncatable-part.component';
|
import { TruncatablePartComponent } from '../../../shared/truncatable/truncatable-part/truncatable-part.component';
|
||||||
import { AdminNotifyDetailModalComponent } from '../admin-notify-detail-modal/admin-notify-detail-modal.component';
|
import { AdminNotifyDetailModalComponent } from '../admin-notify-detail-modal/admin-notify-detail-modal.component';
|
||||||
@@ -90,76 +80,46 @@ export const mockAdminNotifyMessages = [
|
|||||||
describe('AdminNotifySearchResultComponent', () => {
|
describe('AdminNotifySearchResultComponent', () => {
|
||||||
let component: AdminNotifySearchResultComponent;
|
let component: AdminNotifySearchResultComponent;
|
||||||
let fixture: ComponentFixture<AdminNotifySearchResultComponent>;
|
let fixture: ComponentFixture<AdminNotifySearchResultComponent>;
|
||||||
let objectCache: ObjectCacheService;
|
|
||||||
let requestService: RequestService;
|
|
||||||
let halService: HALEndpointService;
|
|
||||||
let rdbService: RemoteDataBuildService;
|
|
||||||
let adminNotifyMessageService: AdminNotifyMessagesService;
|
let adminNotifyMessageService: AdminNotifyMessagesService;
|
||||||
let searchConfigService: SearchConfigurationService;
|
let searchConfigService: SearchConfigurationService;
|
||||||
let modalService: NgbModal;
|
let modalService: NgbModal;
|
||||||
const requestUUID = '34cfed7c-f597-49ef-9cbe-ea351f0023c2';
|
|
||||||
const testObject = {
|
|
||||||
uuid: 'test-property',
|
|
||||||
name: 'test-property',
|
|
||||||
values: ['value-1', 'value-2'],
|
|
||||||
} as ConfigurationProperty;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
halService = jasmine.createSpyObj('halService', {
|
|
||||||
getEndpoint: cold('a', { a: '' }),
|
|
||||||
});
|
|
||||||
adminNotifyMessageService = jasmine.createSpyObj('adminNotifyMessageService', {
|
adminNotifyMessageService = jasmine.createSpyObj('adminNotifyMessageService', {
|
||||||
getDetailedMessages: of(mockAdminNotifyMessages),
|
getDetailedMessages: of(mockAdminNotifyMessages),
|
||||||
reprocessMessage: of(mockAdminNotifyMessages),
|
reprocessMessage: of(mockAdminNotifyMessages),
|
||||||
});
|
});
|
||||||
requestService = jasmine.createSpyObj('requestService', {
|
|
||||||
generateRequestId: requestUUID,
|
|
||||||
send: true,
|
|
||||||
});
|
|
||||||
rdbService = jasmine.createSpyObj('rdbService', {
|
|
||||||
buildSingle: cold('a', {
|
|
||||||
a: {
|
|
||||||
payload: testObject,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
searchConfigService = jasmine.createSpyObj('searchConfigService', {
|
searchConfigService = jasmine.createSpyObj('searchConfigService', {
|
||||||
getCurrentConfiguration: of('NOTIFY.outgoing'),
|
getCurrentConfiguration: of('NOTIFY.outgoing'),
|
||||||
});
|
});
|
||||||
objectCache = {} as ObjectCacheService;
|
|
||||||
|
|
||||||
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), AdminNotifySearchResultComponent, AdminNotifyDetailModalComponent],
|
imports: [
|
||||||
|
AdminNotifyDetailModalComponent,
|
||||||
|
AdminNotifySearchResultComponent,
|
||||||
|
RouterModule.forRoot([]),
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: AdminNotifyMessagesService, useValue: adminNotifyMessageService },
|
{ provide: AdminNotifyMessagesService, useValue: adminNotifyMessageService },
|
||||||
{ provide: RouteService, useValue: routeServiceStub },
|
|
||||||
{ provide: ActivatedRoute, useValue: new RouterStub() },
|
|
||||||
{ provide: HALEndpointService, useValue: halService },
|
|
||||||
{ provide: ObjectCacheService, useValue: objectCache },
|
|
||||||
{ provide: RequestService, useValue: requestService },
|
|
||||||
{ provide: RemoteDataBuildService, useValue: rdbService },
|
|
||||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: searchConfigService },
|
|
||||||
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
|
|
||||||
DatePipe,
|
DatePipe,
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA],
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
})
|
}).overrideProvider(SEARCH_CONFIG_SERVICE, {
|
||||||
.overrideComponent(AdminNotifySearchResultComponent, {
|
useValue: searchConfigService,
|
||||||
remove: {
|
}).overrideComponent(AdminNotifySearchResultComponent, {
|
||||||
imports: [
|
remove: {
|
||||||
TruncatableComponent,
|
imports: [
|
||||||
TruncatablePartComponent,
|
TruncatableComponent,
|
||||||
],
|
TruncatablePartComponent,
|
||||||
},
|
],
|
||||||
})
|
},
|
||||||
.compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(AdminNotifySearchResultComponent);
|
fixture = TestBed.createComponent(AdminNotifySearchResultComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.searchConfigService = searchConfigService;
|
modalService = TestBed.inject(NgbModal);
|
||||||
modalService = (component as any).modalService;
|
|
||||||
spyOn(modalService, 'open').and.returnValue(Object.assign({ componentInstance: Object.assign({ response: observableOf(true) }) }));
|
spyOn(modalService, 'open').and.returnValue(Object.assign({ componentInstance: Object.assign({ response: observableOf(true) }) }));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
@@ -1,38 +1,23 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import {
|
|
||||||
Component,
|
|
||||||
NO_ERRORS_SCHEMA,
|
|
||||||
} from '@angular/core';
|
|
||||||
import {
|
import {
|
||||||
ComponentFixture,
|
ComponentFixture,
|
||||||
TestBed,
|
TestBed,
|
||||||
waitForAsync,
|
waitForAsync,
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterModule } from '@angular/router';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
import { provideMockStore } from '@ngrx/store/testing';
|
import { provideMockStore } from '@ngrx/store/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import {
|
import {
|
||||||
cold,
|
cold,
|
||||||
getTestScheduler,
|
|
||||||
hot,
|
hot,
|
||||||
} from 'jasmine-marbles';
|
} from 'jasmine-marbles';
|
||||||
import {
|
import { of as observableOf } from 'rxjs';
|
||||||
of as observableOf,
|
|
||||||
of,
|
|
||||||
} from 'rxjs';
|
|
||||||
import { TestScheduler } from 'rxjs/testing';
|
|
||||||
|
|
||||||
import { APP_DATA_SERVICES_MAP } from '../../../../config/app-config.interface';
|
|
||||||
import { BitstreamFormatDataService } from '../../../core/data/bitstream-format-data.service';
|
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 { PaginationService } from '../../../core/pagination/pagination.service';
|
||||||
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
|
import { BitstreamFormat } from '../../../core/shared/bitstream-format.model';
|
||||||
import { BitstreamFormatSupportLevel } from '../../../core/shared/bitstream-format-support-level';
|
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 { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
|
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
|
||||||
import {
|
import {
|
||||||
@@ -41,7 +26,6 @@ import {
|
|||||||
createSuccessfulRemoteDataObject,
|
createSuccessfulRemoteDataObject,
|
||||||
createSuccessfulRemoteDataObject$,
|
createSuccessfulRemoteDataObject$,
|
||||||
} from '../../../shared/remote-data.utils';
|
} from '../../../shared/remote-data.utils';
|
||||||
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service.stub';
|
|
||||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||||
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
||||||
@@ -52,7 +36,6 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
let comp: BitstreamFormatsComponent;
|
let comp: BitstreamFormatsComponent;
|
||||||
let fixture: ComponentFixture<BitstreamFormatsComponent>;
|
let fixture: ComponentFixture<BitstreamFormatsComponent>;
|
||||||
let bitstreamFormatService;
|
let bitstreamFormatService;
|
||||||
let scheduler: TestScheduler;
|
|
||||||
let notificationsServiceStub;
|
let notificationsServiceStub;
|
||||||
let paginationService;
|
let paginationService;
|
||||||
|
|
||||||
@@ -107,8 +90,6 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
const initAsync = () => {
|
const initAsync = () => {
|
||||||
notificationsServiceStub = new NotificationsServiceStub();
|
notificationsServiceStub = new NotificationsServiceStub();
|
||||||
|
|
||||||
scheduler = getTestScheduler();
|
|
||||||
|
|
||||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||||
findAll: observableOf(mockFormatsRD),
|
findAll: observableOf(mockFormatsRD),
|
||||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||||
@@ -120,33 +101,28 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
clearBitStreamFormatRequests: observableOf('cleared'),
|
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();
|
paginationService = new PaginationServiceStub();
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
imports: [
|
||||||
|
BitstreamFormatsComponent,
|
||||||
|
EnumKeysPipe,
|
||||||
|
RouterModule.forRoot([]),
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
],
|
||||||
providers: [
|
providers: [
|
||||||
provideMockStore(),
|
provideMockStore(),
|
||||||
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
|
|
||||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
||||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
|
||||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||||
{ provide: PaginationService, useValue: paginationService },
|
{ 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();
|
}).compileComponents();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -251,8 +227,6 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
notificationsServiceStub = new NotificationsServiceStub();
|
notificationsServiceStub = new NotificationsServiceStub();
|
||||||
|
|
||||||
scheduler = getTestScheduler();
|
|
||||||
|
|
||||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||||
findAll: observableOf(mockFormatsRD),
|
findAll: observableOf(mockFormatsRD),
|
||||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||||
@@ -264,37 +238,26 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
clearBitStreamFormatRequests: observableOf('cleared'),
|
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();
|
paginationService = new PaginationServiceStub();
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
BitstreamFormatsComponent,
|
||||||
RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule,
|
EnumKeysPipe,
|
||||||
BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
PaginationComponent,
|
||||||
|
RouterModule.forRoot([]),
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
],
|
||||||
providers: [
|
providers: [
|
||||||
provideMockStore(),
|
provideMockStore(),
|
||||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
||||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
|
||||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
{ 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, {
|
.overrideComponent(BitstreamFormatsComponent, {
|
||||||
remove: { imports: [PaginationComponent] },
|
remove: { imports: [PaginationComponent] },
|
||||||
add: { imports: [TestPaginationComponent] },
|
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
},
|
},
|
||||||
@@ -321,8 +284,6 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
notificationsServiceStub = new NotificationsServiceStub();
|
notificationsServiceStub = new NotificationsServiceStub();
|
||||||
|
|
||||||
scheduler = getTestScheduler();
|
|
||||||
|
|
||||||
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
bitstreamFormatService = jasmine.createSpyObj('bitstreamFormatService', {
|
||||||
findAll: observableOf(mockFormatsRD),
|
findAll: observableOf(mockFormatsRD),
|
||||||
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
find: createSuccessfulRemoteDataObject$(mockFormatsList[0]),
|
||||||
@@ -334,35 +295,24 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
clearBitStreamFormatRequests: observableOf('cleared'),
|
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();
|
paginationService = new PaginationServiceStub();
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule, BitstreamFormatsComponent, PaginationComponent, EnumKeysPipe],
|
imports: [
|
||||||
|
BitstreamFormatsComponent,
|
||||||
|
EnumKeysPipe,
|
||||||
|
RouterModule.forRoot([]),
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
],
|
||||||
providers: [
|
providers: [
|
||||||
provideMockStore(),
|
|
||||||
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
{ provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
|
||||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
|
||||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||||
{ provide: PaginationService, useValue: paginationService },
|
{ 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, {
|
.overrideComponent(BitstreamFormatsComponent, {
|
||||||
remove: { imports: [PaginationComponent] },
|
remove: { imports: [PaginationComponent] },
|
||||||
add: { imports: [TestPaginationComponent] },
|
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
},
|
},
|
||||||
@@ -384,12 +334,3 @@ describe('BitstreamFormatsComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@Component({
|
|
||||||
exportAs: 'paginationComponent',
|
|
||||||
selector: 'ds-pagination',
|
|
||||||
template: ``,
|
|
||||||
standalone: true,
|
|
||||||
})
|
|
||||||
export class TestPaginationComponent {
|
|
||||||
}
|
|
||||||
|
@@ -8,10 +8,7 @@ import {
|
|||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import { RouterLink } from '@angular/router';
|
||||||
Router,
|
|
||||||
RouterLink,
|
|
||||||
} from '@angular/router';
|
|
||||||
import {
|
import {
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
TranslateService,
|
TranslateService,
|
||||||
@@ -74,7 +71,6 @@ export class BitstreamFormatsComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
constructor(private notificationsService: NotificationsService,
|
constructor(private notificationsService: NotificationsService,
|
||||||
private router: Router,
|
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private bitstreamFormatService: BitstreamFormatDataService,
|
private bitstreamFormatService: BitstreamFormatDataService,
|
||||||
private paginationService: PaginationService,
|
private paginationService: PaginationService,
|
||||||
|
@@ -7,6 +7,7 @@ import {
|
|||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { environment } from '../../../../environments/environment.test';
|
||||||
import { getMockRequestService } from '../../../shared/mocks/request.service.mock';
|
import { getMockRequestService } from '../../../shared/mocks/request.service.mock';
|
||||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
@@ -88,7 +89,7 @@ describe('SearchConfigurationService', () => {
|
|||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
service = new SearchConfigurationService(routeService, paginationService as any, activatedRoute as any, linkService, halService, requestService, rdb);
|
service = new SearchConfigurationService(routeService, paginationService as any, activatedRoute as any, linkService, halService, requestService, rdb, environment);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when the scope is called', () => {
|
describe('when the scope is called', () => {
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
Inject,
|
||||||
Injectable,
|
Injectable,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
@@ -20,6 +21,10 @@ import {
|
|||||||
take,
|
take,
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
|
import {
|
||||||
|
APP_CONFIG,
|
||||||
|
AppConfig,
|
||||||
|
} from '../../../../config/app-config.interface';
|
||||||
import {
|
import {
|
||||||
hasNoValue,
|
hasNoValue,
|
||||||
hasValue,
|
hasValue,
|
||||||
@@ -29,6 +34,7 @@ import {
|
|||||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
import { FacetConfigResponse } from '../../../shared/search/models/facet-config-response.model';
|
import { FacetConfigResponse } from '../../../shared/search/models/facet-config-response.model';
|
||||||
|
import { FilterType } from '../../../shared/search/models/filter-type.model';
|
||||||
import { PaginatedSearchOptions } from '../../../shared/search/models/paginated-search-options.model';
|
import { PaginatedSearchOptions } from '../../../shared/search/models/paginated-search-options.model';
|
||||||
import { SearchFilter } from '../../../shared/search/models/search-filter.model';
|
import { SearchFilter } from '../../../shared/search/models/search-filter.model';
|
||||||
import { SearchFilterConfig } from '../../../shared/search/models/search-filter-config.model';
|
import { SearchFilterConfig } from '../../../shared/search/models/search-filter-config.model';
|
||||||
@@ -56,12 +62,8 @@ import {
|
|||||||
getFirstSucceededRemoteData,
|
getFirstSucceededRemoteData,
|
||||||
} from '../operators';
|
} from '../operators';
|
||||||
import { ViewMode } from '../view-mode.model';
|
import { ViewMode } from '../view-mode.model';
|
||||||
import { SearchFilterConfig } from '../../../shared/search/models/search-filter-config.model';
|
|
||||||
import { FacetConfigResponse } from '../../../shared/search/models/facet-config-response.model';
|
|
||||||
import { addOperatorToFilterValue } from '../../../shared/search/search.utils';
|
|
||||||
import { FilterConfig } from './search-filters/search-config.model';
|
|
||||||
import { FilterType } from '../../../shared/search/models/filter-type.model';
|
|
||||||
import {
|
import {
|
||||||
|
FilterConfig,
|
||||||
SearchConfig,
|
SearchConfig,
|
||||||
SortConfig,
|
SortConfig,
|
||||||
} from './search-filters/search-config.model';
|
} from './search-filters/search-config.model';
|
||||||
@@ -126,24 +128,15 @@ export class SearchConfigurationService implements OnDestroy {
|
|||||||
*/
|
*/
|
||||||
protected subs: Map<string, Subscription[]> = new Map<string, Subscription[]>(null);
|
protected subs: Map<string, Subscription[]> = new Map<string, Subscription[]>(null);
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the search options
|
|
||||||
* @param {RouteService} routeService
|
|
||||||
* @param {PaginationService} paginationService
|
|
||||||
* @param {ActivatedRoute} route
|
|
||||||
* @param linkService
|
|
||||||
* @param halService
|
|
||||||
* @param requestService
|
|
||||||
* @param rdb
|
|
||||||
*/
|
|
||||||
constructor(protected routeService: RouteService,
|
constructor(protected routeService: RouteService,
|
||||||
protected paginationService: PaginationService,
|
protected paginationService: PaginationService,
|
||||||
protected route: ActivatedRoute,
|
protected route: ActivatedRoute,
|
||||||
protected linkService: LinkService,
|
protected linkService: LinkService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
protected rdb: RemoteDataBuildService) {
|
protected rdb: RemoteDataBuildService,
|
||||||
|
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||||
|
) {
|
||||||
this.initDefaults();
|
this.initDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +290,7 @@ export class SearchConfigurationService implements OnDestroy {
|
|||||||
return this.getConfigurationSearchConfig(configuration, scope).pipe(
|
return this.getConfigurationSearchConfig(configuration, scope).pipe(
|
||||||
map((searchConfiguration: SearchConfig) => {
|
map((searchConfiguration: SearchConfig) => {
|
||||||
return searchConfiguration.filters
|
return searchConfiguration.filters
|
||||||
|
.filter((filterConfig: FilterConfig) => this.appConfig.search.advancedFilters.filter.includes(filterConfig.filter))
|
||||||
.filter((filterConfig: FilterConfig) => filterConfig.type !== FilterType.range);
|
.filter((filterConfig: FilterConfig) => filterConfig.type !== FilterType.range);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@@ -4,6 +4,7 @@ import {
|
|||||||
} from 'jasmine-marbles';
|
} from 'jasmine-marbles';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
|
import { environment } from '../../environments/environment.test';
|
||||||
import {
|
import {
|
||||||
SortDirection,
|
SortDirection,
|
||||||
SortOptions,
|
SortOptions,
|
||||||
@@ -58,7 +59,7 @@ describe('MyDSpaceConfigurationService', () => {
|
|||||||
const rdb: any = getMockRemoteDataBuildService();
|
const rdb: any = getMockRemoteDataBuildService();
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
service = new MyDSpaceConfigurationService(roleService, spy, paginationService as any, activatedRoute, linkService, halService, requestService, rdb);
|
service = new MyDSpaceConfigurationService(roleService, spy, paginationService as any, activatedRoute, linkService, halService, requestService, rdb, environment);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when the scope is called', () => {
|
describe('when the scope is called', () => {
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
Inject,
|
||||||
Injectable,
|
Injectable,
|
||||||
InjectionToken,
|
InjectionToken,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
@@ -12,6 +13,10 @@ import {
|
|||||||
map,
|
map,
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
|
import {
|
||||||
|
APP_CONFIG,
|
||||||
|
AppConfig,
|
||||||
|
} from '../../config/app-config.interface';
|
||||||
import { LinkService } from '../core/cache/builders/link.service';
|
import { LinkService } from '../core/cache/builders/link.service';
|
||||||
import { RemoteDataBuildService } from '../core/cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../core/cache/builders/remote-data-build.service';
|
||||||
import {
|
import {
|
||||||
@@ -75,18 +80,6 @@ export class MyDSpaceConfigurationService extends SearchConfigurationService {
|
|||||||
private isController$: Observable<boolean>;
|
private isController$: Observable<boolean>;
|
||||||
private isSubmitter$: Observable<boolean>;
|
private isSubmitter$: Observable<boolean>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize class
|
|
||||||
*
|
|
||||||
* @param {roleService} roleService
|
|
||||||
* @param {RouteService} routeService
|
|
||||||
* @param {PaginationService} paginationService
|
|
||||||
* @param {ActivatedRoute} route
|
|
||||||
* @param linkService
|
|
||||||
* @param halService
|
|
||||||
* @param requestService
|
|
||||||
* @param rdb
|
|
||||||
*/
|
|
||||||
constructor(protected roleService: RoleService,
|
constructor(protected roleService: RoleService,
|
||||||
protected routeService: RouteService,
|
protected routeService: RouteService,
|
||||||
protected paginationService: PaginationService,
|
protected paginationService: PaginationService,
|
||||||
@@ -94,9 +87,19 @@ export class MyDSpaceConfigurationService extends SearchConfigurationService {
|
|||||||
protected linkService: LinkService,
|
protected linkService: LinkService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
protected rdb: RemoteDataBuildService) {
|
protected rdb: RemoteDataBuildService,
|
||||||
|
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||||
super(routeService, paginationService, route, linkService, halService, requestService, rdb);
|
) {
|
||||||
|
super(
|
||||||
|
routeService,
|
||||||
|
paginationService,
|
||||||
|
route,
|
||||||
|
linkService,
|
||||||
|
halService,
|
||||||
|
requestService,
|
||||||
|
rdb,
|
||||||
|
appConfig,
|
||||||
|
);
|
||||||
|
|
||||||
// override parent class initialization
|
// override parent class initialization
|
||||||
this._defaults = null;
|
this._defaults = null;
|
||||||
|
@@ -13,15 +13,12 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
|
|
||||||
import { APP_CONFIG } from '../../../../config/app-config.interface';
|
import { APP_CONFIG } from '../../../../config/app-config.interface';
|
||||||
import { environment } from '../../../../environments/environment.test';
|
import { environment } from '../../../../environments/environment.test';
|
||||||
|
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
||||||
|
import { SearchConfigurationServiceStub } from '../../testing/search-configuration-service.stub';
|
||||||
import { AdvancedSearchComponent } from '../advanced-search/advanced-search.component';
|
import { AdvancedSearchComponent } from '../advanced-search/advanced-search.component';
|
||||||
import { ThemedSearchFiltersComponent } from '../search-filters/themed-search-filters.component';
|
import { ThemedSearchFiltersComponent } from '../search-filters/themed-search-filters.component';
|
||||||
import { ThemedSearchSettingsComponent } from '../search-settings/themed-search-settings.component';
|
import { ThemedSearchSettingsComponent } from '../search-settings/themed-search-settings.component';
|
||||||
import { SearchSidebarComponent } from './search-sidebar.component';
|
import { SearchSidebarComponent } from './search-sidebar.component';
|
||||||
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
import { By } from '@angular/platform-browser';
|
|
||||||
import { SearchConfigurationServiceStub } from '../../testing/search-configuration-service.stub';
|
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
||||||
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
|
||||||
|
|
||||||
describe('SearchSidebarComponent', () => {
|
describe('SearchSidebarComponent', () => {
|
||||||
let comp: SearchSidebarComponent;
|
let comp: SearchSidebarComponent;
|
||||||
@@ -39,23 +36,23 @@ describe('SearchSidebarComponent', () => {
|
|||||||
SearchSidebarComponent,
|
SearchSidebarComponent,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: APP_CONFIG, useValue: environment },
|
{ provide: SearchConfigurationService, useValue: searchConfigurationService },
|
||||||
],
|
],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
})
|
}).overrideProvider(APP_CONFIG, {
|
||||||
.overrideComponent(SearchSidebarComponent, {
|
useValue: environment,
|
||||||
remove:{
|
}).overrideComponent(SearchSidebarComponent, {
|
||||||
imports: [
|
remove:{
|
||||||
AdvancedSearchComponent,
|
imports: [
|
||||||
ThemedSearchFiltersComponent,
|
AdvancedSearchComponent,
|
||||||
ThemedSearchSettingsComponent,
|
ThemedSearchFiltersComponent,
|
||||||
],
|
ThemedSearchSettingsComponent,
|
||||||
},
|
],
|
||||||
add: {
|
},
|
||||||
changeDetection: ChangeDetectionStrategy.Default,
|
add: {
|
||||||
},
|
changeDetection: ChangeDetectionStrategy.Default,
|
||||||
})
|
},
|
||||||
.compileComponents(); // compile template and css
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// synchronous beforeEach
|
// synchronous beforeEach
|
||||||
|
Reference in New Issue
Block a user