mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
61133: Post-merge test fixes
This commit is contained in:
@@ -4,27 +4,24 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MockTranslateLoader } from '../../../shared/mocks/mock-translate-loader';
|
||||
import { MetadataValuesComponent } from './metadata-values.component';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Metadatum } from '../../../core/shared/metadatum.model';
|
||||
import { MetadataValue } from '../../../core/shared/metadata.models';
|
||||
|
||||
let comp: MetadataValuesComponent;
|
||||
let fixture: ComponentFixture<MetadataValuesComponent>;
|
||||
|
||||
const mockMetadata = [
|
||||
{
|
||||
key: 'journal.identifier.issn',
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
},
|
||||
{
|
||||
key: 'journal.publisher',
|
||||
language: 'en_US',
|
||||
value: 'a publisher'
|
||||
},
|
||||
{
|
||||
key: 'journal.identifier.description',
|
||||
language: 'en_US',
|
||||
value: 'desc'
|
||||
}] as Metadatum[];
|
||||
}] as MetadataValue[];
|
||||
const mockSeperator = '<br/>';
|
||||
const mockLabel = 'fake.message';
|
||||
|
||||
@@ -47,7 +44,7 @@ describe('MetadataValuesComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(MetadataValuesComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.values = mockMetadata;
|
||||
comp.mdValues = mockMetadata;
|
||||
comp.separator = mockSeperator;
|
||||
comp.label = mockLabel;
|
||||
fixture.detectChanges();
|
||||
|
@@ -1,11 +1,7 @@
|
||||
import { SearchFixedFilterService } from './search-fixed-filter.service';
|
||||
import { ResponseCacheEntry } from '../../../core/cache/response-cache.reducer';
|
||||
import { RouteService } from '../../../shared/services/route.service';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { ResponseCacheService } from '../../../core/cache/response-cache.service';
|
||||
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service';
|
||||
import { FilteredDiscoveryQueryResponse } from '../../../core/cache/response-cache.models';
|
||||
import { PageInfo } from '../../../core/shared/page-info.model';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
||||
describe('SearchFixedFilterService', () => {
|
||||
@@ -20,17 +16,12 @@ describe('SearchFixedFilterService', () => {
|
||||
/* tslint:enable:no-empty */
|
||||
generateRequestId: () => 'fake-id'
|
||||
}) as RequestService;
|
||||
const responseCacheStub = Object.assign(new ResponseCacheService(undefined), {
|
||||
get: () => observableOf(Object.assign(new ResponseCacheEntry(), {
|
||||
response: new FilteredDiscoveryQueryResponse(filterQuery, '200', new PageInfo())
|
||||
}))
|
||||
});
|
||||
const halServiceStub = Object.assign(new HALEndpointService(responseCacheStub, requestServiceStub, undefined), {
|
||||
const halServiceStub = Object.assign(new HALEndpointService(requestServiceStub, undefined), {
|
||||
getEndpoint: () => observableOf('fake-url')
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = new SearchFixedFilterService(routeServiceStub, requestServiceStub, responseCacheStub, halServiceStub);
|
||||
service = new SearchFixedFilterService(routeServiceStub, requestServiceStub, halServiceStub);
|
||||
});
|
||||
|
||||
describe('when getQueryByFilterName is called with a filterName', () => {
|
||||
|
@@ -1,18 +1,19 @@
|
||||
import { MetadataRepresentationType } from '../metadata-representation.model';
|
||||
import { ItemMetadataRepresentation, ItemTypeToValue } from './item-metadata-representation.model';
|
||||
import { Item } from '../../item.model';
|
||||
import { Metadatum } from '../../metadatum.model';
|
||||
import { MetadataMap, MetadataValue } from '../../metadata.models';
|
||||
|
||||
describe('ItemMetadataRepresentation', () => {
|
||||
const valuePrefix = 'Test value for ';
|
||||
const item = new Item();
|
||||
let itemMetadataRepresentation: ItemMetadataRepresentation;
|
||||
item.metadata = Object.keys(ItemTypeToValue).map((key: string) => {
|
||||
return Object.assign(new Metadatum(), {
|
||||
key: ItemTypeToValue[key],
|
||||
const metadataMap = new MetadataMap();
|
||||
for (const key of Object.keys(ItemTypeToValue)) {
|
||||
metadataMap[ItemTypeToValue[key]] = [Object.assign(new MetadataValue(), {
|
||||
value: `${valuePrefix}${ItemTypeToValue[key]}`
|
||||
});
|
||||
});
|
||||
})];
|
||||
}
|
||||
item.metadata = metadataMap;
|
||||
|
||||
for (const itemType of Object.keys(ItemTypeToValue)) {
|
||||
describe(`when creating an ItemMetadataRepresentation with item-type "${itemType}"`, () => {
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import { Metadatum } from '../../metadatum.model';
|
||||
import { MetadatumRepresentation } from './metadatum-representation.model';
|
||||
import { MetadataRepresentationType } from '../metadata-representation.model';
|
||||
import { MetadataValue } from '../../metadata.models';
|
||||
|
||||
describe('MetadatumRepresentation', () => {
|
||||
const itemType = 'Person';
|
||||
const normalMetadatum = Object.assign(new Metadatum(), {
|
||||
const normalMetadatum = Object.assign(new MetadataValue(), {
|
||||
key: 'dc.contributor.author',
|
||||
value: 'Test Author'
|
||||
});
|
||||
const authorityMetadatum = Object.assign(new Metadatum(), {
|
||||
const authorityMetadatum = Object.assign(new MetadataValue(), {
|
||||
key: 'dc.contributor.author',
|
||||
value: 'Test Authority Author',
|
||||
authority: '1234'
|
||||
|
@@ -1,67 +0,0 @@
|
||||
import { Metadatum } from './metadatum.model';
|
||||
|
||||
describe('Metadatum', () => {
|
||||
let metadatum: Metadatum ;
|
||||
|
||||
beforeEach(() => {
|
||||
metadatum = new Metadatum();
|
||||
});
|
||||
|
||||
describe('isVirtual', () => {
|
||||
describe('when the metadatum has no authority key', () => {
|
||||
beforeEach(() => {
|
||||
metadatum.authority = undefined;
|
||||
});
|
||||
|
||||
it('should return false', () => {
|
||||
expect(metadatum.isVirtual).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the metadatum has an authority key', () => {
|
||||
describe('but it doesn\'t start with the virtual prefix', () => {
|
||||
beforeEach(() => {
|
||||
metadatum.authority = 'value';
|
||||
});
|
||||
|
||||
it('should return false', () => {
|
||||
expect(metadatum.isVirtual).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('and it starts with the virtual prefix', () => {
|
||||
beforeEach(() => {
|
||||
metadatum.authority = 'virtual::value';
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
expect(metadatum.isVirtual).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('virtualValue', () => {
|
||||
describe('when the metadatum isn\'t virtual', () => {
|
||||
beforeEach(() => {
|
||||
metadatum.authority = 'value';
|
||||
});
|
||||
|
||||
it('should return undefined', () => {
|
||||
expect(metadatum.virtualValue).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the metadatum is virtual', () => {
|
||||
beforeEach(() => {
|
||||
metadatum.authority = 'virtual::value';
|
||||
});
|
||||
|
||||
it('should return everything in the authority key after virtual::', () => {
|
||||
expect(metadatum.virtualValue).toBe('value');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user