mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge branch 'DS-4515_submit-external-source' of github.com:4Science/dspace-angular into DS-4515_submit-external-source
Conflicts: src/app/submission/import-external/import-external-preview/submission-import-external-preview.component.spec.ts
This commit is contained in:
@@ -103,16 +103,14 @@ describe('SubmissionImportExternalPreviewComponent test suite', () => {
|
|||||||
const expected = [
|
const expected = [
|
||||||
{ key: 'dc.identifier.uri', value: Metadata.first(comp.externalSourceEntry.metadata, 'dc.identifier.uri') }
|
{ key: 'dc.identifier.uri', value: Metadata.first(comp.externalSourceEntry.metadata, 'dc.identifier.uri') }
|
||||||
];
|
];
|
||||||
scheduler.schedule(() => comp.ngOnInit());
|
fixture.detectChanges();
|
||||||
scheduler.flush();
|
|
||||||
|
|
||||||
expect(comp.metadataList).toEqual(expected);
|
expect(comp.metadataList).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should close the modal calling \'activeModal.dismiss\'', () => {
|
it('Should close the modal calling \'activeModal.dismiss\'', () => {
|
||||||
comp.modalRef = jasmine.createSpyObj('modal', ['close', 'dismiss']);
|
comp.modalRef = jasmine.createSpyObj('modal', ['close', 'dismiss']);
|
||||||
scheduler.schedule(() => comp.closeMetadataModal());
|
comp.closeMetadataModal();
|
||||||
scheduler.flush();
|
|
||||||
|
|
||||||
expect(compAsAny.activeModal.dismiss).toHaveBeenCalled();
|
expect(compAsAny.activeModal.dismiss).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { Component, NO_ERRORS_SCHEMA, ChangeDetectorRef } from '@angular/core';
|
import { Component, NO_ERRORS_SCHEMA, ChangeDetectorRef } from '@angular/core';
|
||||||
import { async, TestBed, ComponentFixture, inject } from '@angular/core/testing';
|
import { async, TestBed, ComponentFixture, inject, fakeAsync, tick } from '@angular/core/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
import { SubmissionImportExternalSearchbarComponent, SourceElement } from './submission-import-external-searchbar.component';
|
import { SubmissionImportExternalSearchbarComponent, SourceElement } from './submission-import-external-searchbar.component';
|
||||||
@@ -13,13 +13,17 @@ import { ExternalSource } from '../../../core/shared/external-source.model';
|
|||||||
import { FindListOptions } from '../../../core/data/request.models';
|
import { FindListOptions } from '../../../core/data/request.models';
|
||||||
import { HostWindowService } from '../../../shared/host-window.service';
|
import { HostWindowService } from '../../../shared/host-window.service';
|
||||||
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service.stub';
|
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service.stub';
|
||||||
|
import { getTestScheduler } from 'jasmine-marbles';
|
||||||
|
import { TestScheduler } from 'rxjs/testing';
|
||||||
|
|
||||||
describe('SubmissionImportExternalSearchbarComponent test suite', () => {
|
describe('SubmissionImportExternalSearchbarComponent test suite', () => {
|
||||||
let comp: SubmissionImportExternalSearchbarComponent;
|
let comp: SubmissionImportExternalSearchbarComponent;
|
||||||
let compAsAny: any;
|
let compAsAny: any;
|
||||||
let fixture: ComponentFixture<SubmissionImportExternalSearchbarComponent>;
|
let fixture: ComponentFixture<SubmissionImportExternalSearchbarComponent>;
|
||||||
|
let scheduler: TestScheduler;
|
||||||
|
|
||||||
beforeEach(async (() => {
|
beforeEach(async (() => {
|
||||||
|
scheduler = getTestScheduler();
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
@@ -85,23 +89,25 @@ describe('SubmissionImportExternalSearchbarComponent test suite', () => {
|
|||||||
compAsAny = null;
|
compAsAny = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should init component properly (without initExternalSourceData)', () => {
|
it('Should init component properly (without initExternalSourceData)', fakeAsync(() => {
|
||||||
comp.initExternalSourceData = { sourceId: '', query: '' };
|
comp.initExternalSourceData = { sourceId: '', query: '' };
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
tick();
|
||||||
|
|
||||||
expect(comp.selectedElement).toEqual(sourceList[0]);
|
expect(comp.selectedElement).toEqual(sourceList[0]);
|
||||||
expect(compAsAny.pageInfo).toEqual(paginatedList.pageInfo);
|
expect(compAsAny.pageInfo).toEqual(paginatedList.pageInfo);
|
||||||
expect(comp.sourceList).toEqual(sourceList);
|
expect(comp.sourceList).toEqual(sourceList);
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('Should init component properly (with initExternalSourceData populated)', () => {
|
it('Should init component properly (with initExternalSourceData populated)', fakeAsync(() => {
|
||||||
comp.initExternalSourceData = { query: 'dummy', sourceId: 'ciencia' };
|
comp.initExternalSourceData = { query: 'dummy', sourceId: 'ciencia' };
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
tick();
|
||||||
|
|
||||||
expect(comp.selectedElement).toEqual(sourceList[1]);
|
expect(comp.selectedElement).toEqual(sourceList[1]);
|
||||||
expect(compAsAny.pageInfo).toEqual(paginatedList.pageInfo);
|
expect(compAsAny.pageInfo).toEqual(paginatedList.pageInfo);
|
||||||
expect(comp.sourceList).toEqual(sourceList);
|
expect(comp.sourceList).toEqual(sourceList);
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('Variable \'selectedElement\' should be assigned', () => {
|
it('Variable \'selectedElement\' should be assigned', () => {
|
||||||
const selectedElement = {id: 'orcid', name: 'orcid'};
|
const selectedElement = {id: 'orcid', name: 'orcid'};
|
||||||
@@ -123,7 +129,9 @@ describe('SubmissionImportExternalSearchbarComponent test suite', () => {
|
|||||||
});
|
});
|
||||||
comp.sourceList = sourceList;
|
comp.sourceList = sourceList;
|
||||||
const expected = sourceList.concat(sourceList);
|
const expected = sourceList.concat(sourceList);
|
||||||
comp.onScroll();
|
|
||||||
|
scheduler.schedule(() => comp.onScroll());
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
expect(comp.sourceList).toEqual(expected);
|
expect(comp.sourceList).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user