mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
[CSTPER-138] Fixed failed test
This commit is contained in:
@@ -50,8 +50,7 @@ export const externalSourceMyStaffDb: ExternalSource = {
|
|||||||
/**
|
/**
|
||||||
* Mock for [[ExternalSourceService]]
|
* Mock for [[ExternalSourceService]]
|
||||||
*/
|
*/
|
||||||
export function getMockExternalSourceService():
|
export function getMockExternalSourceService(): ExternalSourceService {
|
||||||
ExternalSourceService {
|
|
||||||
return jasmine.createSpyObj('ExternalSourceService', {
|
return jasmine.createSpyObj('ExternalSourceService', {
|
||||||
findAll: jasmine.createSpy('findAll'),
|
findAll: jasmine.createSpy('findAll'),
|
||||||
getExternalSourceEntries: jasmine.createSpy('getExternalSourceEntries'),
|
getExternalSourceEntries: jasmine.createSpy('getExternalSourceEntries'),
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div *ngIf="routeData.sourceId !== ''" class="col-md-12">
|
<div *ngIf="routeData.sourceId !== ''" class="col-md-12">
|
||||||
<ng-container *ngVar="(entriesRD$ | async) as entriesRD">
|
<ng-container *ngVar="(entriesRD$ | async) as entriesRD">
|
||||||
<h3 *ngIf="entriesRD?.payload?.page?.length !== 0">{{ 'submission.sections.describe.relationship-lookup.selection-tab.title.' + routeData.sourceId | translate}}</h3>
|
<h3 *ngIf="entriesRD && entriesRD?.payload?.page?.length !== 0">{{ 'submission.sections.describe.relationship-lookup.selection-tab.title.' + routeData.sourceId | translate}}</h3>
|
||||||
<ds-viewable-collection *ngIf="entriesRD?.hasSucceeded && !(isLoading$ | async) && entriesRD?.payload?.page?.length > 0" @fadeIn
|
<ds-viewable-collection *ngIf="entriesRD?.hasSucceeded && !(isLoading$ | async) && entriesRD?.payload?.page?.length > 0" @fadeIn
|
||||||
[objects]="entriesRD"
|
[objects]="entriesRD"
|
||||||
[selectionConfig]="{ repeatable: repeatable, listId: listId }"
|
[selectionConfig]="{ repeatable: repeatable, listId: listId }"
|
||||||
|
@@ -19,10 +19,9 @@ import { VarDirective } from '../../shared/utils/var.directive';
|
|||||||
import { routeServiceStub } from '../../shared/testing/route-service.stub';
|
import { routeServiceStub } from '../../shared/testing/route-service.stub';
|
||||||
import { PaginatedSearchOptions } from '../../shared/search/paginated-search-options.model';
|
import { PaginatedSearchOptions } from '../../shared/search/paginated-search-options.model';
|
||||||
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, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
import { ExternalSourceEntry } from '../../core/shared/external-source-entry.model';
|
import { ExternalSourceEntry } from '../../core/shared/external-source-entry.model';
|
||||||
import { SubmissionImportExternalPreviewComponent } from './import-external-preview/submission-import-external-preview.component';
|
import { SubmissionImportExternalPreviewComponent } from './import-external-preview/submission-import-external-preview.component';
|
||||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
|
||||||
|
|
||||||
describe('SubmissionImportExternalComponent test suite', () => {
|
describe('SubmissionImportExternalComponent test suite', () => {
|
||||||
let comp: SubmissionImportExternalComponent;
|
let comp: SubmissionImportExternalComponent;
|
||||||
@@ -40,6 +39,7 @@ describe('SubmissionImportExternalComponent test suite', () => {
|
|||||||
const searchConfigServiceStub = {
|
const searchConfigServiceStub = {
|
||||||
paginatedSearchOptions: mockSearchOptions
|
paginatedSearchOptions: mockSearchOptions
|
||||||
};
|
};
|
||||||
|
const mockExternalSourceService: any = getMockExternalSourceService();
|
||||||
|
|
||||||
beforeEach(async (() => {
|
beforeEach(async (() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -52,7 +52,7 @@ describe('SubmissionImportExternalComponent test suite', () => {
|
|||||||
VarDirective
|
VarDirective
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: ExternalSourceService, useClass: getMockExternalSourceService },
|
{ provide: ExternalSourceService, useValue: mockExternalSourceService },
|
||||||
{ provide: SearchConfigurationService, useValue: searchConfigServiceStub },
|
{ provide: SearchConfigurationService, useValue: searchConfigServiceStub },
|
||||||
{ provide: RouteService, useValue: routeServiceStub },
|
{ provide: RouteService, useValue: routeServiceStub },
|
||||||
{ provide: Router, useValue: new RouterStub() },
|
{ provide: Router, useValue: new RouterStub() },
|
||||||
@@ -91,6 +91,7 @@ describe('SubmissionImportExternalComponent test suite', () => {
|
|||||||
comp = fixture.componentInstance;
|
comp = fixture.componentInstance;
|
||||||
compAsAny = comp;
|
compAsAny = comp;
|
||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
|
mockExternalSourceService.getExternalSourceEntries.and.returnValue(createSuccessfulRemoteDataObject$(createPaginatedList([])))
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -119,17 +120,17 @@ describe('SubmissionImportExternalComponent test suite', () => {
|
|||||||
|
|
||||||
it('Should call \'getExternalSourceEntries\' properly', () => {
|
it('Should call \'getExternalSourceEntries\' properly', () => {
|
||||||
comp.routeData = { sourceId: '', query: '' };
|
comp.routeData = { sourceId: '', query: '' };
|
||||||
comp.isLoading$ = new BehaviorSubject(false);
|
|
||||||
scheduler.schedule(() => compAsAny.retrieveExternalSources('orcidV2', 'test'));
|
scheduler.schedule(() => compAsAny.retrieveExternalSources('orcidV2', 'test'));
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
|
||||||
expect(comp.routeData).toEqual({ sourceId: 'orcidV2', query: 'test' });
|
expect(comp.routeData).toEqual({ sourceId: 'orcidV2', query: 'test' });
|
||||||
expect(comp.isLoading$.value).toBe(true);
|
expect(comp.isLoading$.value).toBe(false);
|
||||||
expect(compAsAny.externalService.getExternalSourceEntries).toHaveBeenCalled();
|
expect(compAsAny.externalService.getExternalSourceEntries).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should call \'router.navigate\'', () => {
|
it('Should call \'router.navigate\'', () => {
|
||||||
spyOn(compAsAny, 'retrieveExternalSources');
|
comp.routeData = { sourceId: '', query: '' };
|
||||||
|
spyOn(compAsAny, 'retrieveExternalSources').and.callFake(() => null);
|
||||||
compAsAny.router.navigate.and.returnValue( new Promise(() => {return;}))
|
compAsAny.router.navigate.and.returnValue( new Promise(() => {return;}))
|
||||||
const event = { sourceId: 'orcidV2', query: 'dummy' };
|
const event = { sourceId: 'orcidV2', query: 'dummy' };
|
||||||
|
|
||||||
|
@@ -39,11 +39,11 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* The displayed list of entries
|
* The displayed list of entries
|
||||||
*/
|
*/
|
||||||
public entriesRD$: BehaviorSubject<RemoteData<PaginatedList<ExternalSourceEntry>>>;
|
public entriesRD$: BehaviorSubject<RemoteData<PaginatedList<ExternalSourceEntry>>> = new BehaviorSubject<RemoteData<PaginatedList<ExternalSourceEntry>>>(null);
|
||||||
/**
|
/**
|
||||||
* TRUE if the REST service is called to retrieve the external source items
|
* TRUE if the REST service is called to retrieve the external source items
|
||||||
*/
|
*/
|
||||||
public isLoading$: BehaviorSubject<boolean>;
|
public isLoading$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||||
/**
|
/**
|
||||||
* Configuration to use for the import buttons
|
* Configuration to use for the import buttons
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user