61133: Post-merge test fixes

This commit is contained in:
Kristof De Langhe
2019-03-15 10:50:34 +01:00
parent a9397f0b11
commit e6d401d195
5 changed files with 15 additions and 93 deletions

View File

@@ -4,27 +4,24 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MockTranslateLoader } from '../../../shared/mocks/mock-translate-loader'; import { MockTranslateLoader } from '../../../shared/mocks/mock-translate-loader';
import { MetadataValuesComponent } from './metadata-values.component'; import { MetadataValuesComponent } from './metadata-values.component';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Metadatum } from '../../../core/shared/metadatum.model'; import { MetadataValue } from '../../../core/shared/metadata.models';
let comp: MetadataValuesComponent; let comp: MetadataValuesComponent;
let fixture: ComponentFixture<MetadataValuesComponent>; let fixture: ComponentFixture<MetadataValuesComponent>;
const mockMetadata = [ const mockMetadata = [
{ {
key: 'journal.identifier.issn',
language: 'en_US', language: 'en_US',
value: '1234' value: '1234'
}, },
{ {
key: 'journal.publisher',
language: 'en_US', language: 'en_US',
value: 'a publisher' value: 'a publisher'
}, },
{ {
key: 'journal.identifier.description',
language: 'en_US', language: 'en_US',
value: 'desc' value: 'desc'
}] as Metadatum[]; }] as MetadataValue[];
const mockSeperator = '<br/>'; const mockSeperator = '<br/>';
const mockLabel = 'fake.message'; const mockLabel = 'fake.message';
@@ -47,7 +44,7 @@ describe('MetadataValuesComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
fixture = TestBed.createComponent(MetadataValuesComponent); fixture = TestBed.createComponent(MetadataValuesComponent);
comp = fixture.componentInstance; comp = fixture.componentInstance;
comp.values = mockMetadata; comp.mdValues = mockMetadata;
comp.separator = mockSeperator; comp.separator = mockSeperator;
comp.label = mockLabel; comp.label = mockLabel;
fixture.detectChanges(); fixture.detectChanges();

View File

@@ -1,11 +1,7 @@
import { SearchFixedFilterService } from './search-fixed-filter.service'; import { SearchFixedFilterService } from './search-fixed-filter.service';
import { ResponseCacheEntry } from '../../../core/cache/response-cache.reducer';
import { RouteService } from '../../../shared/services/route.service'; import { RouteService } from '../../../shared/services/route.service';
import { RequestService } from '../../../core/data/request.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 { 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'; import { of as observableOf } from 'rxjs';
describe('SearchFixedFilterService', () => { describe('SearchFixedFilterService', () => {
@@ -20,17 +16,12 @@ describe('SearchFixedFilterService', () => {
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
generateRequestId: () => 'fake-id' generateRequestId: () => 'fake-id'
}) as RequestService; }) as RequestService;
const responseCacheStub = Object.assign(new ResponseCacheService(undefined), { const halServiceStub = Object.assign(new HALEndpointService(requestServiceStub, undefined), {
get: () => observableOf(Object.assign(new ResponseCacheEntry(), {
response: new FilteredDiscoveryQueryResponse(filterQuery, '200', new PageInfo())
}))
});
const halServiceStub = Object.assign(new HALEndpointService(responseCacheStub, requestServiceStub, undefined), {
getEndpoint: () => observableOf('fake-url') getEndpoint: () => observableOf('fake-url')
}); });
beforeEach(() => { beforeEach(() => {
service = new SearchFixedFilterService(routeServiceStub, requestServiceStub, responseCacheStub, halServiceStub); service = new SearchFixedFilterService(routeServiceStub, requestServiceStub, halServiceStub);
}); });
describe('when getQueryByFilterName is called with a filterName', () => { describe('when getQueryByFilterName is called with a filterName', () => {

View File

@@ -1,18 +1,19 @@
import { MetadataRepresentationType } from '../metadata-representation.model'; import { MetadataRepresentationType } from '../metadata-representation.model';
import { ItemMetadataRepresentation, ItemTypeToValue } from './item-metadata-representation.model'; import { ItemMetadataRepresentation, ItemTypeToValue } from './item-metadata-representation.model';
import { Item } from '../../item.model'; import { Item } from '../../item.model';
import { Metadatum } from '../../metadatum.model'; import { MetadataMap, MetadataValue } from '../../metadata.models';
describe('ItemMetadataRepresentation', () => { describe('ItemMetadataRepresentation', () => {
const valuePrefix = 'Test value for '; const valuePrefix = 'Test value for ';
const item = new Item(); const item = new Item();
let itemMetadataRepresentation: ItemMetadataRepresentation; let itemMetadataRepresentation: ItemMetadataRepresentation;
item.metadata = Object.keys(ItemTypeToValue).map((key: string) => { const metadataMap = new MetadataMap();
return Object.assign(new Metadatum(), { for (const key of Object.keys(ItemTypeToValue)) {
key: ItemTypeToValue[key], metadataMap[ItemTypeToValue[key]] = [Object.assign(new MetadataValue(), {
value: `${valuePrefix}${ItemTypeToValue[key]}` value: `${valuePrefix}${ItemTypeToValue[key]}`
}); })];
}); }
item.metadata = metadataMap;
for (const itemType of Object.keys(ItemTypeToValue)) { for (const itemType of Object.keys(ItemTypeToValue)) {
describe(`when creating an ItemMetadataRepresentation with item-type "${itemType}"`, () => { describe(`when creating an ItemMetadataRepresentation with item-type "${itemType}"`, () => {

View File

@@ -1,14 +1,14 @@
import { Metadatum } from '../../metadatum.model';
import { MetadatumRepresentation } from './metadatum-representation.model'; import { MetadatumRepresentation } from './metadatum-representation.model';
import { MetadataRepresentationType } from '../metadata-representation.model'; import { MetadataRepresentationType } from '../metadata-representation.model';
import { MetadataValue } from '../../metadata.models';
describe('MetadatumRepresentation', () => { describe('MetadatumRepresentation', () => {
const itemType = 'Person'; const itemType = 'Person';
const normalMetadatum = Object.assign(new Metadatum(), { const normalMetadatum = Object.assign(new MetadataValue(), {
key: 'dc.contributor.author', key: 'dc.contributor.author',
value: 'Test Author' value: 'Test Author'
}); });
const authorityMetadatum = Object.assign(new Metadatum(), { const authorityMetadatum = Object.assign(new MetadataValue(), {
key: 'dc.contributor.author', key: 'dc.contributor.author',
value: 'Test Authority Author', value: 'Test Authority Author',
authority: '1234' authority: '1234'

View File

@@ -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');
});
});
});
});