mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
68405: More test fixes
This commit is contained in:

committed by
Art Lowel

parent
be0158fc9c
commit
42d6527ca9
@@ -1,29 +1,37 @@
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader';
|
||||
import { ChangeDetectionStrategy, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { ItemComponent } from './item.component';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { VarDirective } from '../../../../shared/utils/var.directive';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model';
|
||||
import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model';
|
||||
import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||
import { MetadataMap, MetadataValue } from '../../../../core/shared/metadata.models';
|
||||
import { compareArraysUsing, compareArraysUsingIds } from './item-relationships-utils';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { NormalizedObjectBuildService } from '../../../../core/cache/builders/normalized-object-build.service';
|
||||
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||
import { DefaultChangeAnalyzer } from '../../../../core/data/default-change-analyzer.service';
|
||||
import { DSOChangeAnalyzer } from '../../../../core/data/dso-change-analyzer.service';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { RelationshipService } from '../../../../core/data/relationship.service';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
||||
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { UUIDService } from '../../../../core/shared/uuid.service';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { MockTranslateLoader } from '../../../../shared/mocks/mock-translate-loader';
|
||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
||||
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
|
||||
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
|
||||
import { compareArraysUsing, compareArraysUsingIds } from './item-relationships-utils';
|
||||
import { ItemComponent } from './item.component';
|
||||
|
||||
/**
|
||||
* Create a generic test for an item-page-fields component using a mockItem and the type of component
|
||||
@@ -38,6 +46,11 @@ export function getItemPageFieldsTest(mockItem: Item, component) {
|
||||
let fixture: ComponentFixture<any>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
const mockBitstreamDataService = {
|
||||
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
||||
return createSuccessfulRemoteDataObject$(new Bitstream());
|
||||
}
|
||||
};
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot({
|
||||
loader: {
|
||||
@@ -47,14 +60,26 @@ export function getItemPageFieldsTest(mockItem: Item, component) {
|
||||
})],
|
||||
declarations: [component, GenericItemPageFieldComponent, TruncatePipe],
|
||||
providers: [
|
||||
{provide: ItemDataService, useValue: {}},
|
||||
{provide: TruncatableService, useValue: {}},
|
||||
{provide: RelationshipService, useValue: {}}
|
||||
{ provide: ItemDataService, useValue: {} },
|
||||
{ provide: TruncatableService, useValue: {} },
|
||||
{ provide: RelationshipService, useValue: {} },
|
||||
{ provide: ObjectCacheService, useValue: {} },
|
||||
{ provide: UUIDService, useValue: {} },
|
||||
{ provide: Store, useValue: {} },
|
||||
{ provide: RemoteDataBuildService, useValue: {} },
|
||||
{ provide: NormalizedObjectBuildService, useValue: {} },
|
||||
{ provide: CommunityDataService, useValue: {} },
|
||||
{ provide: HALEndpointService, useValue: {} },
|
||||
{ provide: HttpClient, useValue: {} },
|
||||
{ provide: DSOChangeAnalyzer, useValue: {} },
|
||||
{ provide: NotificationsService, useValue: {} },
|
||||
{ provide: DefaultChangeAnalyzer, useValue: {} },
|
||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||
],
|
||||
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(component, {
|
||||
set: {changeDetection: ChangeDetectionStrategy.Default}
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
@@ -102,6 +127,7 @@ export function createRelationshipsObservable() {
|
||||
})
|
||||
]));
|
||||
}
|
||||
|
||||
describe('ItemComponent', () => {
|
||||
const arr1 = [
|
||||
{
|
||||
|
@@ -18,7 +18,13 @@ import { GlobalConfig } from '../../../config/global-config.interface';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { Item } from '../../core/shared/item.model';
|
||||
|
||||
import { MockItem } from '../../shared/mocks/mock-item';
|
||||
import {
|
||||
MockBitstream1,
|
||||
MockBitstream2,
|
||||
MockBitstreamFormat1,
|
||||
MockBitstreamFormat2,
|
||||
MockItem
|
||||
} from '../../shared/mocks/mock-item';
|
||||
import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
@@ -40,6 +46,7 @@ import { ItemDataService } from '../data/item-data.service';
|
||||
import { PaginatedList } from '../data/paginated-list';
|
||||
import { FindListOptions } from '../data/request.models';
|
||||
import { RequestService } from '../data/request.service';
|
||||
import { BitstreamFormat } from '../shared/bitstream-format.model';
|
||||
import { Bitstream } from '../shared/bitstream.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { MetadataValue } from '../shared/metadata.models';
|
||||
@@ -104,9 +111,27 @@ describe('MetadataService', () => {
|
||||
remoteDataBuildService = new RemoteDataBuildService(objectCacheService, undefined, requestService);
|
||||
const mockBitstreamDataService = {
|
||||
findAllByItemAndBundleName(item: Item, bundleName: string, options?: FindListOptions, ...linksToFollow: Array<FollowLinkConfig<Bitstream>>): Observable<RemoteData<PaginatedList<Bitstream>>> {
|
||||
return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), []));
|
||||
if (item.equals(MockItem)) {
|
||||
return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [MockBitstream1, MockBitstream2]));
|
||||
} else {
|
||||
return createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), []));
|
||||
}
|
||||
},
|
||||
};
|
||||
const mockBitstreamFormatDataService = {
|
||||
findByBitstream(bitstream: Bitstream): Observable<RemoteData<BitstreamFormat>> {
|
||||
switch (bitstream) {
|
||||
case MockBitstream1:
|
||||
return createSuccessfulRemoteDataObject$(MockBitstreamFormat1);
|
||||
break;
|
||||
case MockBitstream2:
|
||||
return createSuccessfulRemoteDataObject$(MockBitstreamFormat2);
|
||||
break;
|
||||
default:
|
||||
return createSuccessfulRemoteDataObject$(new BitstreamFormat());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
@@ -145,7 +170,7 @@ describe('MetadataService', () => {
|
||||
{ provide: DSOChangeAnalyzer, useValue: {} },
|
||||
{ provide: CommunityDataService, useValue: {} },
|
||||
{ provide: DefaultChangeAnalyzer, useValue: {} },
|
||||
{ provide: BitstreamFormatDataService, useValue: {} },
|
||||
{ provide: BitstreamFormatDataService, useValue: mockBitstreamFormatDataService },
|
||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||
Meta,
|
||||
Title,
|
||||
|
@@ -19,10 +19,7 @@ import { BitstreamFormat } from '../shared/bitstream-format.model';
|
||||
import { Bitstream } from '../shared/bitstream.model';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { Item } from '../shared/item.model';
|
||||
import {
|
||||
getFirstSucceededRemoteDataPayload,
|
||||
getFirstSucceededRemoteListPayload
|
||||
} from '../shared/operators';
|
||||
import { getFirstSucceededRemoteDataPayload, getFirstSucceededRemoteListPayload } from '../shared/operators';
|
||||
|
||||
@Injectable()
|
||||
export class MetadataService {
|
||||
@@ -278,12 +275,12 @@ export class MetadataService {
|
||||
.subscribe((bitstreams: Bitstream[]) => {
|
||||
for (const bitstream of bitstreams) {
|
||||
this.bitstreamFormatDataService.findByBitstream(bitstream).pipe(
|
||||
getFirstSucceededRemoteDataPayload()
|
||||
).subscribe((format: BitstreamFormat) => {
|
||||
if (format.mimetype === 'application/pdf') {
|
||||
this.addMetaTag('citation_pdf_url', bitstream._links.content.href);
|
||||
}
|
||||
});
|
||||
getFirstSucceededRemoteDataPayload()
|
||||
).subscribe((format: BitstreamFormat) => {
|
||||
if (format.mimetype === 'application/pdf') {
|
||||
this.addMetaTag('citation_pdf_url', bitstream._links.content.href);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -363,7 +360,7 @@ export class MetadataService {
|
||||
|
||||
public clearMetaTags() {
|
||||
this.tagStore.forEach((tags: MetaDefinition[], property: string) => {
|
||||
this.meta.removeTag("property='" + property + "'");
|
||||
this.meta.removeTag('property=\'' + property + '\'');
|
||||
});
|
||||
this.tagStore.clear();
|
||||
}
|
||||
|
@@ -1,14 +1,12 @@
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { PersonComponent } from './person.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import {
|
||||
createRelationshipsObservable,
|
||||
getItemPageFieldsTest
|
||||
} from '../../../../+item-page/simple/item-types/shared/item.component.spec';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||
import { PersonComponent } from './person.component';
|
||||
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bundles: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
||||
|
@@ -1,21 +1,20 @@
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Community } from '../../../../core/shared/community.model';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { SharedModule } from '../../../shared.module';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { DataService } from '../../../../core/data/data.service';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ComcolMetadataComponent } from './comcol-metadata.component';
|
||||
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../../testing/utils';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { ComColDataService } from '../../../../core/data/comcol-data.service';
|
||||
import { NotificationsServiceStub } from '../../../testing/notifications-service-stub';
|
||||
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Community } from '../../../../core/shared/community.model';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { NotificationsService } from '../../../notifications/notifications.service';
|
||||
import { SharedModule } from '../../../shared.module';
|
||||
import { NotificationsServiceStub } from '../../../testing/notifications-service-stub';
|
||||
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../../testing/utils';
|
||||
import { ComcolMetadataComponent } from './comcol-metadata.component';
|
||||
|
||||
describe('ComColMetadataComponent', () => {
|
||||
let comp: ComcolMetadataComponent<DSpaceObject>;
|
||||
|
@@ -1,11 +1,75 @@
|
||||
import {of as observableOf, Observable } from 'rxjs';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { BitstreamFormat } from '../../core/shared/bitstream-format.model';
|
||||
import { Bitstream } from '../../core/shared/bitstream.model';
|
||||
|
||||
import { Item } from '../../core/shared/item.model';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { Bitstream } from '../../core/shared/bitstream.model';
|
||||
import { PaginatedList } from '../../core/data/paginated-list';
|
||||
import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../testing/utils';
|
||||
|
||||
export const MockBitstreamFormat1: BitstreamFormat = Object.assign(new BitstreamFormat(), {
|
||||
shortDescription: 'Microsoft Word XML',
|
||||
description: 'Microsoft Word XML',
|
||||
mimetype: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
supportLevel: 0,
|
||||
internal: false,
|
||||
extensions: null,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreamformats/10'
|
||||
});
|
||||
|
||||
export const MockBitstreamFormat2: BitstreamFormat = Object.assign(new BitstreamFormat(), {
|
||||
shortDescription: 'Adobe PDF',
|
||||
description: 'Adobe Portable Document Format',
|
||||
mimetype: 'application/pdf',
|
||||
supportLevel: 0,
|
||||
internal: false,
|
||||
extensions: null,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreamformats/4'
|
||||
});
|
||||
|
||||
export const MockBitstream1: Bitstream = Object.assign(new Bitstream(),
|
||||
{
|
||||
sizeBytes: 10201,
|
||||
content: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713/content',
|
||||
format: observableOf(MockBitstreamFormat1),
|
||||
bundleName: 'ORIGINAL',
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||
id: 'cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||
uuid: 'cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||
type: 'bitstream',
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: null,
|
||||
value: 'test_word.docx'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
export const MockBitstream2: Bitstream = Object.assign(new Bitstream(), {
|
||||
sizeBytes: 31302,
|
||||
content: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28/content',
|
||||
format: observableOf(MockBitstreamFormat2),
|
||||
bundleName: 'ORIGINAL',
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28',
|
||||
id: '99b00f3c-1cc6-4689-8158-91965bee6b28',
|
||||
uuid: '99b00f3c-1cc6-4689-8158-91965bee6b28',
|
||||
type: 'bitstream',
|
||||
_links: {
|
||||
self: { href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28' },
|
||||
content: { href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28/content' },
|
||||
format: { href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreamformats/4' },
|
||||
bundle: { href: '' }
|
||||
},
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: null,
|
||||
value: 'test_pdf.pdf'
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
/* tslint:disable:no-shadowed-variable */
|
||||
export const MockItem: Item = Object.assign(new Item(), {
|
||||
handle: '10673/6',
|
||||
@@ -39,76 +103,8 @@ export const MockItem: Item = Object.assign(new Item(), {
|
||||
currentPage: 2
|
||||
},
|
||||
page: [
|
||||
{
|
||||
sizeBytes: 10201,
|
||||
content: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713/content',
|
||||
format: observableOf({
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreamformats/10',
|
||||
requestPending: false,
|
||||
responsePending: false,
|
||||
isSuccessful: true,
|
||||
errorMessage: '',
|
||||
statusCode: '202',
|
||||
pageInfo: {},
|
||||
payload: {
|
||||
shortDescription: 'Microsoft Word XML',
|
||||
description: 'Microsoft Word XML',
|
||||
mimetype: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
supportLevel: 0,
|
||||
internal: false,
|
||||
extensions: null,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreamformats/10'
|
||||
}
|
||||
}),
|
||||
bundleName: 'ORIGINAL',
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||
id: 'cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||
uuid: 'cf9b0c8e-a1eb-4b65-afd0-567366448713',
|
||||
type: 'bitstream',
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: null,
|
||||
value: 'test_word.docx'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
sizeBytes: 31302,
|
||||
content: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28/content',
|
||||
format: observableOf({
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreamformats/4',
|
||||
requestPending: false,
|
||||
responsePending: false,
|
||||
isSuccessful: true,
|
||||
errorMessage: '',
|
||||
statusCode: '202',
|
||||
pageInfo: {},
|
||||
payload: {
|
||||
shortDescription: 'Adobe PDF',
|
||||
description: 'Adobe Portable Document Format',
|
||||
mimetype: 'application/pdf',
|
||||
supportLevel: 0,
|
||||
internal: false,
|
||||
extensions: null,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreamformats/4'
|
||||
}
|
||||
}),
|
||||
bundleName: 'ORIGINAL',
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28',
|
||||
id: '99b00f3c-1cc6-4689-8158-91965bee6b28',
|
||||
uuid: '99b00f3c-1cc6-4689-8158-91965bee6b28',
|
||||
type: 'bitstream',
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: null,
|
||||
value: 'test_pdf.pdf'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
MockBitstream1,
|
||||
MockBitstream2
|
||||
]
|
||||
}
|
||||
}))
|
||||
@@ -228,5 +224,6 @@ export const MockItem: Item = Object.assign(new Item(), {
|
||||
pageInfo: {},
|
||||
payload: []
|
||||
}
|
||||
)});
|
||||
)
|
||||
});
|
||||
/* tslint:enable:no-shadowed-variable */
|
||||
|
@@ -1,15 +1,30 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils';
|
||||
import { NormalizedObjectBuildService } from '../../../../../core/cache/builders/normalized-object-build.service';
|
||||
import { RemoteDataBuildService } from '../../../../../core/cache/builders/remote-data-build.service';
|
||||
import { ObjectCacheService } from '../../../../../core/cache/object-cache.service';
|
||||
import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service';
|
||||
import { CommunityDataService } from '../../../../../core/data/community-data.service';
|
||||
import { DefaultChangeAnalyzer } from '../../../../../core/data/default-change-analyzer.service';
|
||||
import { DSOChangeAnalyzer } from '../../../../../core/data/dso-change-analyzer.service';
|
||||
import { PaginatedList } from '../../../../../core/data/paginated-list';
|
||||
import { RemoteData } from '../../../../../core/data/remote-data';
|
||||
import { Bitstream } from '../../../../../core/shared/bitstream.model';
|
||||
import { HALEndpointService } from '../../../../../core/shared/hal-endpoint.service';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { PageInfo } from '../../../../../core/shared/page-info.model';
|
||||
import { UUIDService } from '../../../../../core/shared/uuid.service';
|
||||
import { NotificationsService } from '../../../../notifications/notifications.service';
|
||||
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { PublicationSearchResultGridElementComponent } from './publication-search-result-grid-element.component';
|
||||
|
||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||
@@ -78,12 +93,30 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
const mockBitstreamDataService = {
|
||||
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
||||
return createSuccessfulRemoteDataObject$(new Bitstream());
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [component, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
{ provide: ObjectCacheService, useValue: {} },
|
||||
{ provide: UUIDService, useValue: {} },
|
||||
{ provide: Store, useValue: {} },
|
||||
{ provide: RemoteDataBuildService, useValue: {} },
|
||||
{ provide: NormalizedObjectBuildService, useValue: {} },
|
||||
{ provide: CommunityDataService, useValue: {} },
|
||||
{ provide: HALEndpointService, useValue: {} },
|
||||
{ provide: HttpClient, useValue: {} },
|
||||
{ provide: DSOChangeAnalyzer, useValue: {} },
|
||||
{ provide: NotificationsService, useValue: {} },
|
||||
{ provide: DefaultChangeAnalyzer, useValue: {} },
|
||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(component, {
|
||||
|
Reference in New Issue
Block a user