"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/app/submission/import-external/submission-import-external.component.spec.ts" between
dspace-angular-dspace-7.0.tar.gz and dspace-angular-dspace-7.1.tar.gz

About: dspace-angular is the Angular-based frontend of DSpace, a digital repository system to capture, store, index, preserve and redistribute an organization’s research material in digital formats.

submission-import-external.component.spec.ts  (dspace-angular-dspace-7.0):submission-import-external.component.spec.ts  (dspace-angular-dspace-7.1)
import { Component, NO_ERRORS_SCHEMA } from '@angular/core'; import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
import { waitForAsync, ComponentFixture, inject, TestBed } from '@angular/core/t esting'; import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/t esting';
import { getTestScheduler } from 'jasmine-marbles'; import { getTestScheduler } from 'jasmine-marbles';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { TestScheduler } from 'rxjs/testing'; import { TestScheduler } from 'rxjs/testing';
import { SubmissionImportExternalComponent } from './submission-import-external. component'; import { SubmissionImportExternalComponent } from './submission-import-external. component';
import { ExternalSourceService } from '../../core/data/external-source.service'; import { ExternalSourceService } from '../../core/data/external-source.service';
skipping to change at line 105 skipping to change at line 105
}); });
afterEach(() => { afterEach(() => {
fixture.destroy(); fixture.destroy();
comp = null; comp = null;
compAsAny = null; compAsAny = null;
}); });
it('Should init component properly (without route data)', () => { it('Should init component properly (without route data)', () => {
const expectedEntries = createSuccessfulRemoteDataObject(createPaginatedLi st([])); const expectedEntries = createSuccessfulRemoteDataObject(createPaginatedLi st([]));
comp.routeData = {entity: '', sourceId: '', query: '' };
spyOn(compAsAny.routeService, 'getQueryParameterValue').and.returnValue(ob servableOf('')); spyOn(compAsAny.routeService, 'getQueryParameterValue').and.returnValue(ob servableOf(''));
fixture.detectChanges(); fixture.detectChanges();
expect(comp.routeData).toEqual({ sourceId: '', query: '' }); expect(comp.routeData).toEqual({entity: '', sourceId: '', query: '' });
expect(comp.isLoading$.value).toBe(false); expect(comp.isLoading$.value).toBe(false);
expect(comp.entriesRD$.value).toEqual(expectedEntries); expect(comp.entriesRD$.value).toEqual(expectedEntries);
}); });
it('Should init component properly (with route data)', () => { it('Should init component properly (with route data)', () => {
comp.routeData = {entity: '', sourceId: '', query: '' };
spyOn(compAsAny, 'retrieveExternalSources'); spyOn(compAsAny, 'retrieveExternalSources');
spyOn(compAsAny.routeService, 'getQueryParameterValue').and.returnValues(o bservableOf('source'), observableOf('dummy')); spyOn(compAsAny.routeService, 'getQueryParameterValue').and.returnValues(o bservableOf('entity'), observableOf('source'), observableOf('dummy'));
fixture.detectChanges(); fixture.detectChanges();
expect(compAsAny.retrieveExternalSources).toHaveBeenCalled(); expect(compAsAny.retrieveExternalSources).toHaveBeenCalled();
}); });
it('Should call \'getExternalSourceEntries\' properly', () => { it('Should call \'getExternalSourceEntries\' properly', () => {
spyOn(routeServiceStub, 'getQueryParameterValue').and.callFake((param) => { spyOn(routeServiceStub, 'getQueryParameterValue').and.callFake((param) => {
if (param === 'source') { if (param === 'sourceId') {
return observableOf('orcidV2'); return observableOf('orcidV2');
} else if (param === 'query') { } else if (param === 'query') {
return observableOf('test'); return observableOf('test');
} }
return observableOf({}); return observableOf({});
}); });
fixture.detectChanges(); fixture.detectChanges();
expect(comp.isLoading$.value).toBe(false); expect(comp.isLoading$.value).toBe(false);
expect(compAsAny.externalService.getExternalSourceEntries).toHaveBeenCalle d(); expect(compAsAny.externalService.getExternalSourceEntries).toHaveBeenCalle d();
}); });
it('Should call \'router.navigate\'', () => { it('Should call \'router.navigate\'', () => {
comp.routeData = { sourceId: '', query: '' }; comp.routeData = {entity: 'Person', sourceId: '', query: '' };
spyOn(compAsAny, 'retrieveExternalSources').and.callFake(() => null); 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 = {entity: 'Person', sourceId: 'orcidV2', query: 'dummy' };
scheduler.schedule(() => comp.getExternalSourceData(event)); scheduler.schedule(() => comp.getExternalSourceData(event));
scheduler.flush(); scheduler.flush();
expect(compAsAny.router.navigate).toHaveBeenCalledWith([], { queryParams: { source: event.sourceId, query: event.query }, replaceUrl: true }); expect(compAsAny.router.navigate).toHaveBeenCalledWith([], { queryParams: { entity: event.entity, sourceId: event.sourceId, query: event.query }, replaceU rl: true });
}); });
it('Entry should be passed to the component loaded inside the modal', () => { it('Entry should be passed to the component loaded inside the modal', () => {
const entry = Object.assign(new ExternalSourceEntry(), { const entry = Object.assign(new ExternalSourceEntry(), {
id: '0001-0001-0001-0001', id: '0001-0001-0001-0001',
display: 'John Doe', display: 'John Doe',
value: 'John, Doe', value: 'John, Doe',
metadata: { metadata: {
'dc.identifier.uri': [ 'dc.identifier.uri': [
{ {
skipping to change at line 168 skipping to change at line 170
} }
] ]
} }
}); });
ngbModal.open.and.returnValue({componentInstance: { externalSourceEntry: n ull}}); ngbModal.open.and.returnValue({componentInstance: { externalSourceEntry: n ull}});
comp.import(entry); comp.import(entry);
expect(compAsAny.modalService.open).toHaveBeenCalledWith(SubmissionImportE xternalPreviewComponent, { size: 'lg' }); expect(compAsAny.modalService.open).toHaveBeenCalledWith(SubmissionImportE xternalPreviewComponent, { size: 'lg' });
expect(comp.modalRef.componentInstance.externalSourceEntry).toEqual(entry) ; expect(comp.modalRef.componentInstance.externalSourceEntry).toEqual(entry) ;
}); });
it('Should set the correct label', () => {
const label = 'Person';
compAsAny.selectLabel(label);
expect(comp.label).toEqual(label);
});
}); });
}); });
// declare a test component // declare a test component
@Component({ @Component({
selector: 'ds-test-cmp', selector: 'ds-test-cmp',
template: `` template: ``
}) })
class TestComponent { class TestComponent {
 End of changes. 10 change blocks. 
7 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)