mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #312 from atmire/No-files-item-page-bugfix
Issue 311: No files item page bugfix
This commit is contained in:
@@ -34,6 +34,9 @@ import { MockItem } from '../../shared/mocks/mock-item';
|
||||
import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader';
|
||||
import { BrowseService } from '../browse/browse.service';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { PaginatedList } from '../data/paginated-list';
|
||||
import { PageInfo } from '../shared/page-info.model';
|
||||
import { EmptyError } from 'rxjs/util/EmptyError';
|
||||
|
||||
/* tslint:disable:max-classes-per-file */
|
||||
@Component({
|
||||
@@ -181,6 +184,22 @@ describe('MetadataService', () => {
|
||||
expect(tagStore.get('description')[0].content).toEqual('This is a dummy item component for testing!');
|
||||
}));
|
||||
|
||||
describe('when the item has no bitstreams', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(MockItem, 'getFiles').and.returnValue(Observable.of([]));
|
||||
});
|
||||
|
||||
it('processRemoteData should not produce an EmptyError', fakeAsync(() => {
|
||||
spyOn(itemDataService, 'findById').and.returnValue(mockRemoteData(MockItem));
|
||||
spyOn(metadataService, 'processRemoteData').and.callThrough();
|
||||
router.navigate(['/items/0ec7ff22-f211-40ab-a69e-c819b0b1f357']);
|
||||
tick();
|
||||
expect(metadataService.processRemoteData).not.toThrow(new EmptyError());
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
const mockRemoteData = (mockItem: Item): Observable<RemoteData<Item>> => {
|
||||
return Observable.of(new RemoteData<Item>(
|
||||
false,
|
||||
|
@@ -269,7 +269,10 @@ export class MetadataService {
|
||||
private setCitationPdfUrlTag(): void {
|
||||
if (this.currentObject.value instanceof Item) {
|
||||
const item = this.currentObject.value as Item;
|
||||
item.getFiles().filter((files) => isNotEmpty(files)).first().subscribe((bitstreams: Bitstream[]) => {
|
||||
item.getFiles()
|
||||
.first((files) => isNotEmpty(files))
|
||||
.catch((error) => { console.debug(error); return [] })
|
||||
.subscribe((bitstreams: Bitstream[]) => {
|
||||
for (const bitstream of bitstreams) {
|
||||
bitstream.format.first()
|
||||
.map((rd: RemoteData<BitstreamFormat>) => rd.payload)
|
||||
|
Reference in New Issue
Block a user