"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/app/submission/import-external/import-external-searchbar/submission-import-external-searchbar.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-searchbar.component.spec.ts  (dspace-angular-dspace-7.0):submission-import-external-searchbar.component.spec.ts  (dspace-angular-dspace-7.1)
skipping to change at line 18 skipping to change at line 18
} from './submission-import-external-searchbar.component'; } from './submission-import-external-searchbar.component';
import { ExternalSourceService } from '../../../core/data/external-source.servic e'; import { ExternalSourceService } from '../../../core/data/external-source.servic e';
import { createTestComponent } from '../../../shared/testing/utils.test'; import { createTestComponent } from '../../../shared/testing/utils.test';
import { import {
externalSourceCiencia, externalSourceCiencia,
externalSourceMyStaffDb, externalSourceMyStaffDb,
externalSourceOrcid, externalSourceOrcid,
getMockExternalSourceService getMockExternalSourceService
} from '../../../shared/mocks/external-source.service.mock'; } from '../../../shared/mocks/external-source.service.mock';
import { PageInfo } from '../../../core/shared/page-info.model'; import { PageInfo } from '../../../core/shared/page-info.model';
import { PaginatedList, buildPaginatedList } from '../../../core/data/paginated- list.model'; import { buildPaginatedList, PaginatedList } from '../../../core/data/paginated- list.model';
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.ut ils'; import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.ut ils';
import { ExternalSource } from '../../../core/shared/external-source.model'; 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-servi ce.stub'; import { HostWindowServiceStub } from '../../../shared/testing/host-window-servi ce.stub';
import { getTestScheduler } from 'jasmine-marbles'; import { getTestScheduler } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs/testing'; import { TestScheduler } from 'rxjs/testing';
import { RequestParam } from '../../../core/cache/models/request-param.model';
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; let scheduler: TestScheduler;
let sourceList: SourceElement[]; let sourceList: SourceElement[];
let paginatedList: PaginatedList<ExternalSource>; let paginatedList: PaginatedList<ExternalSource>;
const mockExternalSourceService: any = getMockExternalSourceService(); const mockExternalSourceService: any = getMockExternalSourceService();
skipping to change at line 66 skipping to change at line 67
}).compileComponents().then(); }).compileComponents().then();
})); }));
// First test to check the correct component creation // First test to check the correct component creation
describe('', () => { describe('', () => {
let testComp: TestComponent; let testComp: TestComponent;
let testFixture: ComponentFixture<TestComponent>; let testFixture: ComponentFixture<TestComponent>;
// synchronous beforeEach // synchronous beforeEach
beforeEach(() => { beforeEach(() => {
mockExternalSourceService.findAll.and.returnValue(observableOf(paginatedLi stRD)); mockExternalSourceService.searchBy.and.returnValue(observableOf(paginatedL istRD));
const html = ` const html = `
<ds-submission-import-external-searchbar></ds-submission-import-external -searchbar>`; <ds-submission-import-external-searchbar [initExternalSourceData]="initE xternalSourceData"></ds-submission-import-external-searchbar>`;
testFixture = createTestComponent(html, TestComponent) as ComponentFixture <TestComponent>; testFixture = createTestComponent(html, TestComponent) as ComponentFixture <TestComponent>;
testComp = testFixture.componentInstance; testComp = testFixture.componentInstance;
}); });
afterEach(() => { afterEach(() => {
testFixture.destroy(); testFixture.destroy();
}); });
it('should create SubmissionImportExternalSearchbarComponent', inject([Submi ssionImportExternalSearchbarComponent], (app: SubmissionImportExternalSearchbarC omponent) => { it('should create SubmissionImportExternalSearchbarComponent', inject([Submi ssionImportExternalSearchbarComponent], (app: SubmissionImportExternalSearchbarC omponent) => {
expect(app).toBeDefined(); expect(app).toBeDefined();
skipping to change at line 91 skipping to change at line 92
describe('', () => { describe('', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(SubmissionImportExternalSearchbarCompone nt); fixture = TestBed.createComponent(SubmissionImportExternalSearchbarCompone nt);
comp = fixture.componentInstance; comp = fixture.componentInstance;
compAsAny = comp; compAsAny = comp;
const pageInfo = new PageInfo(); const pageInfo = new PageInfo();
paginatedList = buildPaginatedList(pageInfo, [externalSourceOrcid, externa lSourceCiencia, externalSourceMyStaffDb]); paginatedList = buildPaginatedList(pageInfo, [externalSourceOrcid, externa lSourceCiencia, externalSourceMyStaffDb]);
paginatedListRD = createSuccessfulRemoteDataObject(paginatedList); paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
compAsAny.externalService.findAll.and.returnValue(observableOf(paginatedLi stRD)); compAsAny.externalService.searchBy.and.returnValue(observableOf(paginatedL istRD));
sourceList = [ sourceList = [
{id: 'orcid', name: 'orcid'}, {id: 'orcid', name: 'orcid'},
{id: 'ciencia', name: 'ciencia'}, {id: 'ciencia', name: 'ciencia'},
{id: 'my_staff_db', name: 'my_staff_db'}, {id: 'my_staff_db', name: 'my_staff_db'},
]; ];
}); });
afterEach(() => { afterEach(() => {
fixture.destroy(); fixture.destroy();
comp = null; comp = null;
compAsAny = null; compAsAny = null;
}); });
it('Should init component properly (without initExternalSourceData)', () => { it('Should init component properly (without initExternalSourceData)', () => {
comp.initExternalSourceData = { sourceId: '', query: '' }; comp.initExternalSourceData = { entity: 'Publication', sourceId: '', query : '' };
scheduler.schedule(() => fixture.detectChanges()); scheduler.schedule(() => fixture.detectChanges());
scheduler.flush(); scheduler.flush();
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)', () => {
comp.initExternalSourceData = { query: 'dummy', sourceId: 'ciencia' }; comp.initExternalSourceData = { entity: 'Publication', query: 'dummy', sou rceId: 'ciencia' };
scheduler.schedule(() => fixture.detectChanges()); scheduler.schedule(() => fixture.detectChanges());
scheduler.flush(); scheduler.flush();
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'};
comp.makeSourceSelection(selectedElement); comp.makeSourceSelection(selectedElement);
expect(comp.selectedElement).toEqual(selectedElement); expect(comp.selectedElement).toEqual(selectedElement);
}); });
it('Should load additional external sources', () => { it('Should load additional external sources', () => {
comp.initExternalSourceData = { entity: 'Publication', query: 'dummy', sou rceId: 'ciencia' };
comp.sourceListLoading = false; comp.sourceListLoading = false;
compAsAny.pageInfo = new PageInfo({ compAsAny.pageInfo = new PageInfo({
elementsPerPage: 3, elementsPerPage: 3,
totalElements: 6, totalElements: 6,
totalPages: 2, totalPages: 2,
currentPage: 0 currentPage: 0
}); });
compAsAny.findListOptions = Object.assign({}, new FindListOptions(), { compAsAny.findListOptions = Object.assign({}, new FindListOptions(), {
elementsPerPage: 3, elementsPerPage: 3,
currentPage: 0, currentPage: 0,
searchParams: [
new RequestParam('entityType', 'Publication')
]
}); });
comp.sourceList = sourceList; comp.sourceList = sourceList;
const expected = sourceList.concat(sourceList); const expected = sourceList.concat(sourceList);
scheduler.schedule(() => comp.onScroll()); scheduler.schedule(() => comp.onScroll());
scheduler.flush(); scheduler.flush();
expect(comp.sourceList).toEqual(expected); expect(comp.sourceList).toEqual(expected);
}); });
it('The \'search\' method should call \'emit\'', () => { it('The \'search\' method should call \'emit\'', () => {
comp.initExternalSourceData = { entity: 'Publication', query: 'dummy', sou rceId: 'ciencia' };
comp.selectedElement = { id: 'orcidV2', name: 'orcidV2' }; comp.selectedElement = { id: 'orcidV2', name: 'orcidV2' };
comp.searchString = 'dummy'; comp.searchString = 'dummy';
const expected = { sourceId: comp.selectedElement.id, query: comp.searchSt ring }; const expected = { entity: 'Publication', sourceId: comp.selectedElement.i d, query: comp.searchString };
spyOn(comp.externalSourceData, 'emit'); spyOn(comp.externalSourceData, 'emit');
comp.search(); comp.search();
expect(comp.externalSourceData.emit).toHaveBeenCalledWith(expected); expect(comp.externalSourceData.emit).toHaveBeenCalledWith(expected);
}); });
}); });
}); });
// declare a test component // declare a test component
@Component({ @Component({
selector: 'ds-test-cmp', selector: 'ds-test-cmp',
template: `` template: ``
}) })
class TestComponent { class TestComponent {
initExternalSourceData = { entity: 'Publication', query: 'dummy', sourceId: 'c iencia' };
} }
 End of changes. 12 change blocks. 
8 lines changed or deleted 14 lines changed or added

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