mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 20:43:08 +00:00
61133: Post-merge test fixing and refactoring
This commit is contained in:
@@ -5,21 +5,21 @@ import { MockTranslateLoader } from '../../../shared/mocks/mock-translate-loader
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { MetadataUriValuesComponent } from './metadata-uri-values.component';
|
||||
import { isNotEmpty } from '../../../shared/empty.util';
|
||||
import { MetadataValue } from '../../../core/shared/metadata.models';
|
||||
|
||||
let comp: MetadataUriValuesComponent;
|
||||
let fixture: ComponentFixture<MetadataUriValuesComponent>;
|
||||
|
||||
const mockMetadata = [
|
||||
{
|
||||
key: 'dc.identifier.uri',
|
||||
language: 'en_US',
|
||||
value: 'http://fakelink.org'
|
||||
},
|
||||
{
|
||||
key: 'dc.identifier.uri',
|
||||
language: 'en_US',
|
||||
value: 'http://another.fakelink.org'
|
||||
}];
|
||||
}
|
||||
] as MetadataValue[];
|
||||
const mockSeperator = '<br/>';
|
||||
const mockLabel = 'fake.message';
|
||||
const mockLinkText = 'fake link text';
|
||||
@@ -43,7 +43,7 @@ describe('MetadataUriValuesComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(MetadataUriValuesComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.values = mockMetadata;
|
||||
comp.mdValues = mockMetadata;
|
||||
comp.separator = mockSeperator;
|
||||
comp.label = mockLabel;
|
||||
fixture.detectChanges();
|
||||
|
@@ -20,12 +20,14 @@ import { By } from '@angular/platform-browser';
|
||||
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []))),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'test item'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'test item'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const routeStub = Object.assign(new ActivatedRouteStub(), {
|
||||
data: observableOf({ item: new RemoteData(false, false, true, null, mockItem) })
|
||||
@@ -69,7 +71,7 @@ describe('FullItemPageComponent', () => {
|
||||
|
||||
it('should display the item\'s metadata', () => {
|
||||
const table = fixture.debugElement.query(By.css('table'));
|
||||
for (const metadatum of mockItem.metadata) {
|
||||
for (const metadatum of mockItem.allMetadata([])) {
|
||||
expect(table.nativeElement.innerHTML).toContain(metadatum.value);
|
||||
}
|
||||
})
|
||||
|
@@ -10,6 +10,7 @@ import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { ItemPageFieldComponent } from './item-page-field.component';
|
||||
import { MetadataValuesComponent } from '../../../field-components/metadata-values/metadata-values.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { MetadataMap } from '../../../../core/shared/metadata.models';
|
||||
|
||||
let comp: ItemPageFieldComponent;
|
||||
let fixture: ComponentFixture<ItemPageFieldComponent>;
|
||||
@@ -50,13 +51,13 @@ describe('ItemPageFieldComponent', () => {
|
||||
});
|
||||
|
||||
export function mockItemWithMetadataFieldAndValue(field: string, value: string): Item {
|
||||
return Object.assign(new Item(), {
|
||||
const item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []))),
|
||||
metadata: [
|
||||
{
|
||||
key: field,
|
||||
language: 'en_US',
|
||||
value: value
|
||||
}]
|
||||
metadata: new MetadataMap()
|
||||
});
|
||||
item.metadata[field] = [{
|
||||
language: 'en_US',
|
||||
value: value
|
||||
}];
|
||||
return item;
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ import { RouteService } from '../../../shared/services/route.service';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { RequestEntry } from '../../../core/data/request.reducer';
|
||||
import { FilteredDiscoveryQueryResponse, RestResponse } from '../../../core/cache/response.models';
|
||||
|
||||
describe('SearchFixedFilterService', () => {
|
||||
let service: SearchFixedFilterService;
|
||||
@@ -14,7 +16,10 @@ describe('SearchFixedFilterService', () => {
|
||||
/* tslint:disable:no-empty */
|
||||
configure: () => {},
|
||||
/* tslint:enable:no-empty */
|
||||
generateRequestId: () => 'fake-id'
|
||||
generateRequestId: () => 'fake-id',
|
||||
getByUUID: () => observableOf(Object.assign(new RequestEntry(), {
|
||||
response: new FilteredDiscoveryQueryResponse(filterQuery, '200')
|
||||
}))
|
||||
}) as RequestService;
|
||||
const halServiceStub = Object.assign(new HALEndpointService(requestServiceStub, undefined), {
|
||||
getEndpoint: () => observableOf('fake-url')
|
||||
|
@@ -8,7 +8,7 @@ import { ResponseParsingService } from '../../../core/data/parsing.service';
|
||||
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
||||
import { FilteredDiscoveryPageResponseParsingService } from '../../../core/data/filtered-discovery-page-response-parsing.service';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
import { configureRequest } from '../../../core/shared/operators';
|
||||
import { configureRequest, getResponseFromEntry } from '../../../core/shared/operators';
|
||||
import { RouteService } from '../../../shared/services/route.service';
|
||||
import { FilteredDiscoveryQueryResponse } from '../../../core/cache/response.models';
|
||||
|
||||
@@ -33,7 +33,7 @@ export class SearchFixedFilterService {
|
||||
getQueryByFilterName(filterName: string): Observable<string> {
|
||||
if (hasValue(filterName)) {
|
||||
const requestUuid = this.requestService.generateRequestId();
|
||||
const requestObs = this.halService.getEndpoint(this.queryByFilterPath).pipe(
|
||||
this.halService.getEndpoint(this.queryByFilterPath).pipe(
|
||||
map((url: string) => {
|
||||
url += ('/' + filterName);
|
||||
const request = new GetRequest(requestUuid, url);
|
||||
@@ -44,10 +44,11 @@ export class SearchFixedFilterService {
|
||||
});
|
||||
}),
|
||||
configureRequest(this.requestService)
|
||||
);
|
||||
).subscribe();
|
||||
|
||||
// get search results from response cache
|
||||
const filterQuery: Observable<string> = this.requestService.getByUUID(requestUuid).pipe(
|
||||
getResponseFromEntry(),
|
||||
map((response: FilteredDiscoveryQueryResponse) =>
|
||||
response.filterQuery
|
||||
));
|
||||
|
@@ -9,7 +9,7 @@ import {
|
||||
import { Metadata } from './metadata.utils';
|
||||
|
||||
const mdValue = (value: string, language?: string): MetadataValue => {
|
||||
return { uuid: uuidv4(), value: value, language: isUndefined(language) ? null : language };
|
||||
return Object.assign(new MetadataValue(), { uuid: uuidv4(), value: value, language: isUndefined(language) ? null : language, place: 0, authority: undefined, confidence: undefined });
|
||||
};
|
||||
|
||||
const dcDescription = mdValue('Some description');
|
||||
|
@@ -16,17 +16,20 @@ import { VIEW_MODE_METADATA } from '../../../+item-page/simple/metadata-represen
|
||||
const relationType = 'type';
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []))),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'test item'
|
||||
},
|
||||
{
|
||||
key: 'relationship.type',
|
||||
language: 'en_US',
|
||||
value: relationType
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'test item'
|
||||
}
|
||||
],
|
||||
'relationship.type': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: relationType
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemMetadataRepresentation = Object.assign(new ItemMetadataRepresentation(relationType), mockItem);
|
||||
let viewMode = VIEW_MODE_FULL;
|
||||
|
@@ -13,31 +13,37 @@ let fixture: ComponentFixture<JournalIssueListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'journalvolume.identifier.volume',
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
},
|
||||
{
|
||||
key: 'journalissue.identifier.number',
|
||||
language: 'en_US',
|
||||
value: '5678'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'journalvolume.identifier.volume': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
}
|
||||
],
|
||||
'journalissue.identifier.number': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: '5678'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('JournalIssueListElementComponent', () => {
|
||||
|
@@ -13,31 +13,37 @@ let fixture: ComponentFixture<JournalVolumeListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'journal.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another journal title'
|
||||
},
|
||||
{
|
||||
key: 'journalvolume.identifier.volume',
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'journal.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another journal title'
|
||||
}
|
||||
],
|
||||
'journalvolume.identifier.volume': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('JournalVolumeListElementComponent', () => {
|
||||
|
@@ -13,26 +13,31 @@ let fixture: ComponentFixture<JournalListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'journal.identifier.issn',
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'journal.identifier.issn': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('JournalListElementComponent', () => {
|
||||
|
@@ -13,26 +13,31 @@ let fixture: ComponentFixture<OrgUnitListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'orgunit.identifier.description',
|
||||
language: 'en_US',
|
||||
value: 'A description about the OrgUnit'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'orgunit.identifier.description': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'A description about the OrgUnit'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('OrgUnitListElementComponent', () => {
|
||||
|
@@ -13,26 +13,31 @@ let fixture: ComponentFixture<PersonListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'person.identifier.jobtitle',
|
||||
language: 'en_US',
|
||||
value: 'Developer'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'person.identifier.jobtitle': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'Developer'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('PersonListElementComponent', () => {
|
||||
|
@@ -13,26 +13,31 @@ let fixture: ComponentFixture<ProjectListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'project.identifier.status',
|
||||
language: 'en_US',
|
||||
value: 'A status about the project'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'project.identifier.status': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'A status about the project'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('ProjectListElementComponent', () => {
|
||||
|
@@ -4,9 +4,9 @@
|
||||
[innerHTML]="firstMetadataValue('dc.title')"></a>
|
||||
<span class="text-muted">
|
||||
<ds-truncatable-part [id]="item.id" [minLines]="1">
|
||||
<ng-container *ngIf="item.allMetadata('dc.publisher') || item.allMetadata('dc.date.issued')">(<span class="item-list-publisher"
|
||||
<ng-container *ngIf="item.firstMetadataValue('dc.publisher') || item.firstMetadataValue('dc.date.issued')">(<span class="item-list-publisher"
|
||||
[innerHTML]="firstMetadataValue('dc.publisher')">, </span><span
|
||||
*ngIf="item.allMetadata('dc.date.issued')" class="item-list-date"
|
||||
*ngIf="item.firstMetadataValue('dc.date.issued')" class="item-list-date"
|
||||
[innerHTML]="firstMetadataValue('dc.date.issued')"></span>)</ng-container>
|
||||
<span *ngIf="item.allMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']).length > 0"
|
||||
class="item-list-authors">
|
||||
@@ -16,7 +16,7 @@
|
||||
</span>
|
||||
</ds-truncatable-part>
|
||||
</span>
|
||||
<div *ngIf="item.allMetadata('dc.description.abstract')" class="item-list-abstract">
|
||||
<div *ngIf="item.firstMetadataValue('dc.description.abstract')" class="item-list-abstract">
|
||||
<ds-truncatable-part [id]="item.id" [minLines]="3"><span
|
||||
[innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
|
||||
</ds-truncatable-part>
|
||||
|
@@ -13,41 +13,49 @@ let fixture: ComponentFixture<PublicationListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'dc.contributor.author',
|
||||
language: 'en_US',
|
||||
value: 'Smith, Donald'
|
||||
},
|
||||
{
|
||||
key: 'dc.publisher',
|
||||
language: 'en_US',
|
||||
value: 'a publisher'
|
||||
},
|
||||
{
|
||||
key: 'dc.date.issued',
|
||||
language: null,
|
||||
value: '2015-06-26'
|
||||
},
|
||||
{
|
||||
key: 'dc.description.abstract',
|
||||
language: 'en_US',
|
||||
value: 'This is the abstract'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
],
|
||||
'dc.contributor.author': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'Smith, Donald'
|
||||
}
|
||||
],
|
||||
'dc.publisher': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'a publisher'
|
||||
}
|
||||
],
|
||||
'dc.date.issued': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: '2015-06-26'
|
||||
}
|
||||
],
|
||||
'dc.description.abstract': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is the abstract'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
describe('PublicationListElementComponent', () => {
|
||||
|
Reference in New Issue
Block a user