"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/app/item-page/simple/item-types/publication/publication.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.

publication.component.spec.ts  (dspace-angular-dspace-7.0):publication.component.spec.ts  (dspace-angular-dspace-7.1)
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs'; import { Observable, of } from 'rxjs';
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-d ata-build.service'; import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-d ata-build.service';
import { ObjectCacheService } from '../../../../core/cache/object-cache.service' ; import { ObjectCacheService } from '../../../../core/cache/object-cache.service' ;
import { BitstreamDataService } from '../../../../core/data/bitstream-data.servi ce'; import { BitstreamDataService } from '../../../../core/data/bitstream-data.servi ce';
import { CommunityDataService } from '../../../../core/data/community-data.servi ce'; import { CommunityDataService } from '../../../../core/data/community-data.servi ce';
import { DefaultChangeAnalyzer } from '../../../../core/data/default-change-anal yzer.service'; import { DefaultChangeAnalyzer } from '../../../../core/data/default-change-anal yzer.service';
import { DSOChangeAnalyzer } from '../../../../core/data/dso-change-analyzer.ser vice'; import { DSOChangeAnalyzer } from '../../../../core/data/dso-change-analyzer.ser vice';
import { ItemDataService } from '../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../core/data/item-data.service';
import { RelationshipService } from '../../../../core/data/relationship.service' ; import { RelationshipService } from '../../../../core/data/relationship.service' ;
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
import { Bitstream } from '../../../../core/shared/bitstream.model'; import { Bitstream } from '../../../../core/shared/bitstream.model';
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service '; import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service ';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { MetadataMap } from '../../../../core/shared/metadata.models'; import { MetadataMap } from '../../../../core/shared/metadata.models';
import { UUIDService } from '../../../../core/shared/uuid.service'; import { UUIDService } from '../../../../core/shared/uuid.service';
import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.m ock'; import { TranslateLoaderMock } from '../../../../shared/mocks/translate-loader.m ock';
import { NotificationsService } from '../../../../shared/notifications/notificat ions.service'; import { NotificationsService } from '../../../../shared/notifications/notificat ions.service';
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-dat a.utils'; import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-dat a.utils';
import { TruncatableService } from '../../../../shared/truncatable/truncatable.s ervice'; import { TruncatableService } from '../../../../shared/truncatable/truncatable.s ervice';
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe'; import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
import { GenericItemPageFieldComponent } from '../../field-components/specific-f ield/generic/generic-item-page-field.component'; import { GenericItemPageFieldComponent } from '../../field-components/specific-f ield/generic/generic-item-page-field.component';
import { createRelationshipsObservable } from '../shared/item.component.spec'; import {
createRelationshipsObservable,
iiifEnabled,
iiifSearchEnabled, mockRouteService
} from '../shared/item.component.spec';
import { PublicationComponent } from './publication.component'; import { PublicationComponent } from './publication.component';
import { createPaginatedList } from '../../../../shared/testing/utils.test'; import { createPaginatedList } from '../../../../shared/testing/utils.test';
import { RouteService } from '../../../../core/services/route.service';
const mockItem: Item = Object.assign(new Item(), { const iiifEnabledMap: MetadataMap = {
bundles: createSuccessfulRemoteDataObject$(createPaginatedList([])), 'dspace.iiif.enabled': [iiifEnabled],
metadata: new MetadataMap(), };
relationships: createRelationshipsObservable()
}); const iiifEnabledWithSearchMap: MetadataMap = {
'dspace.iiif.enabled': [iiifEnabled],
'iiif.search.enabled': [iiifSearchEnabled],
};
const noMetadata = new MetadataMap();
function getItem(metadata: MetadataMap) {
return Object.assign(new Item(), {
bundles: createSuccessfulRemoteDataObject$(createPaginatedList([])),
metadata: metadata,
relationships: createRelationshipsObservable()
});
}
describe('PublicationComponent', () => { describe('PublicationComponent', () => {
let comp: PublicationComponent; let comp: PublicationComponent;
let fixture: ComponentFixture<PublicationComponent>; let fixture: ComponentFixture<PublicationComponent>;
beforeEach(waitForAsync(() => { beforeEach(waitForAsync(() => {
const mockBitstreamDataService = { const mockBitstreamDataService = {
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> { getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
return createSuccessfulRemoteDataObject$(new Bitstream()); return createSuccessfulRemoteDataObject$(new Bitstream());
} }
skipping to change at line 71 skipping to change at line 89
{ provide: UUIDService, useValue: {} }, { provide: UUIDService, useValue: {} },
{ provide: Store, useValue: {} }, { provide: Store, useValue: {} },
{ provide: RemoteDataBuildService, useValue: {} }, { provide: RemoteDataBuildService, useValue: {} },
{ provide: CommunityDataService, useValue: {} }, { provide: CommunityDataService, useValue: {} },
{ provide: HALEndpointService, useValue: {} }, { provide: HALEndpointService, useValue: {} },
{ provide: NotificationsService, useValue: {} }, { provide: NotificationsService, useValue: {} },
{ provide: HttpClient, useValue: {} }, { provide: HttpClient, useValue: {} },
{ provide: DSOChangeAnalyzer, useValue: {} }, { provide: DSOChangeAnalyzer, useValue: {} },
{ provide: DefaultChangeAnalyzer, useValue: {} }, { provide: DefaultChangeAnalyzer, useValue: {} },
{ provide: BitstreamDataService, useValue: mockBitstreamDataService }, { provide: BitstreamDataService, useValue: mockBitstreamDataService },
{ provide: RouteService, useValue: mockRouteService }
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
}).overrideComponent(PublicationComponent, { }).overrideComponent(PublicationComponent, {
set: { changeDetection: ChangeDetectionStrategy.Default } set: { changeDetection: ChangeDetectionStrategy.Default }
}).compileComponents(); }).compileComponents();
})); }));
beforeEach(waitForAsync(() => { describe('default view', () => {
fixture = TestBed.createComponent(PublicationComponent); beforeEach(waitForAsync(() => {
comp = fixture.componentInstance; fixture = TestBed.createComponent(PublicationComponent);
comp.object = mockItem; comp = fixture.componentInstance;
fixture.detectChanges(); comp.object = getItem(noMetadata);
})); fixture.detectChanges();
}));
it('should contain a component to display the date', () => {
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-date-field it('should contain a component to display the date', () => {
')); const fields = fixture.debugElement.queryAll(By.css('ds-item-page-date-fie
expect(fields.length).toBeGreaterThanOrEqual(1); ld'));
}); expect(fields.length).toBeGreaterThanOrEqual(1);
});
it('should not contain a metadata only author field', () => {
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-author-fie it('should not contain a metadata only author field', () => {
ld')); const fields = fixture.debugElement.queryAll(By.css('ds-item-page-author-f
expect(fields.length).toBe(0); ield'));
}); expect(fields.length).toBe(0);
});
it('should contain a mixed metadata and relationship field for authors', () =>
{ it('should contain a mixed metadata and relationship field for authors', ()
const fields = fixture.debugElement.queryAll(By.css('.ds-item-page-mixed-aut => {
hor-field')); const fields = fixture.debugElement.queryAll(By.css('.ds-item-page-mixed-a
expect(fields.length).toBe(1); uthor-field'));
}); expect(fields.length).toBe(1);
});
it('should contain a component to display the abstract', () => {
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-abstract-f it('should contain a component to display the abstract', () => {
ield')); const fields = fixture.debugElement.queryAll(By.css('ds-item-page-abstract
expect(fields.length).toBeGreaterThanOrEqual(1); -field'));
}); expect(fields.length).toBeGreaterThanOrEqual(1);
});
it('should contain a component to display the uri', () => {
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-uri-field' it('should contain a component to display the uri', () => {
)); const fields = fixture.debugElement.queryAll(By.css('ds-item-page-uri-fiel
expect(fields.length).toBeGreaterThanOrEqual(1); d'));
}); expect(fields.length).toBeGreaterThanOrEqual(1);
});
it('should contain a component to display the collections', () => {
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-collecti
ons'));
expect(fields.length).toBeGreaterThanOrEqual(1);
});
});
describe('with IIIF viewer', () => {
beforeEach(waitForAsync(() => {
fixture = TestBed.createComponent(PublicationComponent);
comp = fixture.componentInstance;
comp.object = getItem(iiifEnabledMap);
fixture.detectChanges();
}));
it('should contain an iiif viewer component', () => {
const fields = fixture.debugElement.queryAll(By.css('ds-mirador-viewer'));
expect(fields.length).toBeGreaterThanOrEqual(1);
});
});
describe('with IIIF viewer and search', () => {
beforeEach(waitForAsync(() => {
mockRouteService.getPreviousUrl.and.returnValue(of(['/search?q=bird&motiva
tion=painting','/item']));
fixture = TestBed.createComponent(PublicationComponent);
comp = fixture.componentInstance;
comp.object = getItem(iiifEnabledWithSearchMap);
fixture.detectChanges();
}));
it('should contain an iiif viewer component', () => {
const fields = fixture.debugElement.queryAll(By.css('ds-mirador-viewer'));
expect(fields.length).toBeGreaterThanOrEqual(1);
});
it('should call the RouteService getHistory method', () => {
expect(mockRouteService.getPreviousUrl).toHaveBeenCalled();
});
it('should contain a component to display the collections', () => {
const fields = fixture.debugElement.queryAll(By.css('ds-item-page-collection
s'));
expect(fields.length).toBeGreaterThanOrEqual(1);
}); });
}); });
 End of changes. 7 change blocks. 
48 lines changed or deleted 107 lines changed or added

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