mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +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 { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
|
import { Store } from '@ngrx/store';
|
||||||
import { TruncatableService } from '../../../../shared/truncatable/truncatable.service';
|
|
||||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
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 { Observable } from 'rxjs/internal/Observable';
|
||||||
import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model';
|
import { NormalizedObjectBuildService } from '../../../../core/cache/builders/normalized-object-build.service';
|
||||||
import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model';
|
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
|
||||||
import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||||
import { MetadataMap, MetadataValue } from '../../../../core/shared/metadata.models';
|
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||||
import { compareArraysUsing, compareArraysUsingIds } from './item-relationships-utils';
|
import { CommunityDataService } from '../../../../core/data/community-data.service';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
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 { 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
|
* 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>;
|
let fixture: ComponentFixture<any>;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
|
const mockBitstreamDataService = {
|
||||||
|
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
||||||
|
return createSuccessfulRemoteDataObject$(new Bitstream());
|
||||||
|
}
|
||||||
|
};
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot({
|
imports: [TranslateModule.forRoot({
|
||||||
loader: {
|
loader: {
|
||||||
@@ -47,14 +60,26 @@ export function getItemPageFieldsTest(mockItem: Item, component) {
|
|||||||
})],
|
})],
|
||||||
declarations: [component, GenericItemPageFieldComponent, TruncatePipe],
|
declarations: [component, GenericItemPageFieldComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{provide: ItemDataService, useValue: {}},
|
{ provide: ItemDataService, useValue: {} },
|
||||||
{provide: TruncatableService, useValue: {}},
|
{ provide: TruncatableService, useValue: {} },
|
||||||
{provide: RelationshipService, 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]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(component, {
|
}).overrideComponent(component, {
|
||||||
set: {changeDetection: ChangeDetectionStrategy.Default}
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -102,6 +127,7 @@ export function createRelationshipsObservable() {
|
|||||||
})
|
})
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('ItemComponent', () => {
|
describe('ItemComponent', () => {
|
||||||
const arr1 = [
|
const arr1 = [
|
||||||
{
|
{
|
||||||
|
@@ -18,7 +18,13 @@ import { GlobalConfig } from '../../../config/global-config.interface';
|
|||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { Item } from '../../core/shared/item.model';
|
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 { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader';
|
||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||||
@@ -40,6 +46,7 @@ import { ItemDataService } from '../data/item-data.service';
|
|||||||
import { PaginatedList } from '../data/paginated-list';
|
import { PaginatedList } from '../data/paginated-list';
|
||||||
import { FindListOptions } from '../data/request.models';
|
import { FindListOptions } from '../data/request.models';
|
||||||
import { RequestService } from '../data/request.service';
|
import { RequestService } from '../data/request.service';
|
||||||
|
import { BitstreamFormat } from '../shared/bitstream-format.model';
|
||||||
import { Bitstream } from '../shared/bitstream.model';
|
import { Bitstream } from '../shared/bitstream.model';
|
||||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
import { MetadataValue } from '../shared/metadata.models';
|
import { MetadataValue } from '../shared/metadata.models';
|
||||||
@@ -104,9 +111,27 @@ describe('MetadataService', () => {
|
|||||||
remoteDataBuildService = new RemoteDataBuildService(objectCacheService, undefined, requestService);
|
remoteDataBuildService = new RemoteDataBuildService(objectCacheService, undefined, requestService);
|
||||||
const mockBitstreamDataService = {
|
const mockBitstreamDataService = {
|
||||||
findAllByItemAndBundleName(item: Item, bundleName: string, options?: FindListOptions, ...linksToFollow: Array<FollowLinkConfig<Bitstream>>): Observable<RemoteData<PaginatedList<Bitstream>>> {
|
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({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -145,7 +170,7 @@ describe('MetadataService', () => {
|
|||||||
{ provide: DSOChangeAnalyzer, useValue: {} },
|
{ provide: DSOChangeAnalyzer, useValue: {} },
|
||||||
{ provide: CommunityDataService, useValue: {} },
|
{ provide: CommunityDataService, useValue: {} },
|
||||||
{ provide: DefaultChangeAnalyzer, useValue: {} },
|
{ provide: DefaultChangeAnalyzer, useValue: {} },
|
||||||
{ provide: BitstreamFormatDataService, useValue: {} },
|
{ provide: BitstreamFormatDataService, useValue: mockBitstreamFormatDataService },
|
||||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||||
Meta,
|
Meta,
|
||||||
Title,
|
Title,
|
||||||
|
@@ -19,10 +19,7 @@ import { BitstreamFormat } from '../shared/bitstream-format.model';
|
|||||||
import { Bitstream } from '../shared/bitstream.model';
|
import { Bitstream } from '../shared/bitstream.model';
|
||||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||||
import { Item } from '../shared/item.model';
|
import { Item } from '../shared/item.model';
|
||||||
import {
|
import { getFirstSucceededRemoteDataPayload, getFirstSucceededRemoteListPayload } from '../shared/operators';
|
||||||
getFirstSucceededRemoteDataPayload,
|
|
||||||
getFirstSucceededRemoteListPayload
|
|
||||||
} from '../shared/operators';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MetadataService {
|
export class MetadataService {
|
||||||
@@ -278,12 +275,12 @@ export class MetadataService {
|
|||||||
.subscribe((bitstreams: Bitstream[]) => {
|
.subscribe((bitstreams: Bitstream[]) => {
|
||||||
for (const bitstream of bitstreams) {
|
for (const bitstream of bitstreams) {
|
||||||
this.bitstreamFormatDataService.findByBitstream(bitstream).pipe(
|
this.bitstreamFormatDataService.findByBitstream(bitstream).pipe(
|
||||||
getFirstSucceededRemoteDataPayload()
|
getFirstSucceededRemoteDataPayload()
|
||||||
).subscribe((format: BitstreamFormat) => {
|
).subscribe((format: BitstreamFormat) => {
|
||||||
if (format.mimetype === 'application/pdf') {
|
if (format.mimetype === 'application/pdf') {
|
||||||
this.addMetaTag('citation_pdf_url', bitstream._links.content.href);
|
this.addMetaTag('citation_pdf_url', bitstream._links.content.href);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -363,7 +360,7 @@ export class MetadataService {
|
|||||||
|
|
||||||
public clearMetaTags() {
|
public clearMetaTags() {
|
||||||
this.tagStore.forEach((tags: MetaDefinition[], property: string) => {
|
this.tagStore.forEach((tags: MetaDefinition[], property: string) => {
|
||||||
this.meta.removeTag("property='" + property + "'");
|
this.meta.removeTag('property=\'' + property + '\'');
|
||||||
});
|
});
|
||||||
this.tagStore.clear();
|
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 {
|
import {
|
||||||
createRelationshipsObservable,
|
createRelationshipsObservable,
|
||||||
getItemPageFieldsTest
|
getItemPageFieldsTest
|
||||||
} from '../../../../+item-page/simple/item-types/shared/item.component.spec';
|
} 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 { createSuccessfulRemoteDataObject$ } from '../../../../shared/testing/utils';
|
||||||
|
import { PersonComponent } from './person.component';
|
||||||
|
|
||||||
const mockItem: Item = Object.assign(new Item(), {
|
const mockItem: Item = Object.assign(new Item(), {
|
||||||
bundles: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
|
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 { 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 { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { ComcolMetadataComponent } from './comcol-metadata.component';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../../testing/utils';
|
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 { 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 { 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', () => {
|
describe('ComColMetadataComponent', () => {
|
||||||
let comp: ComcolMetadataComponent<DSpaceObject>;
|
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 { 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';
|
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 */
|
/* tslint:disable:no-shadowed-variable */
|
||||||
export const MockItem: Item = Object.assign(new Item(), {
|
export const MockItem: Item = Object.assign(new Item(), {
|
||||||
handle: '10673/6',
|
handle: '10673/6',
|
||||||
@@ -39,76 +103,8 @@ export const MockItem: Item = Object.assign(new Item(), {
|
|||||||
currentPage: 2
|
currentPage: 2
|
||||||
},
|
},
|
||||||
page: [
|
page: [
|
||||||
{
|
MockBitstream1,
|
||||||
sizeBytes: 10201,
|
MockBitstream2
|
||||||
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'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@@ -228,5 +224,6 @@ export const MockItem: Item = Object.assign(new Item(), {
|
|||||||
pageInfo: {},
|
pageInfo: {},
|
||||||
payload: []
|
payload: []
|
||||||
}
|
}
|
||||||
)});
|
)
|
||||||
|
});
|
||||||
/* tslint:enable:no-shadowed-variable */
|
/* tslint:enable:no-shadowed-variable */
|
||||||
|
@@ -1,15 +1,30 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
||||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
|
||||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
|
||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
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 { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
|
import { NormalizedObjectBuildService } from '../../../../../core/cache/builders/normalized-object-build.service';
|
||||||
import { Item } from '../../../../../core/shared/item.model';
|
import { RemoteDataBuildService } from '../../../../../core/cache/builders/remote-data-build.service';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../../testing/utils';
|
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 { 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 { 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';
|
import { PublicationSearchResultGridElementComponent } from './publication-search-result-grid-element.component';
|
||||||
|
|
||||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
@@ -78,12 +93,30 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet
|
|||||||
isCollapsed: (id: number) => observableOf(true),
|
isCollapsed: (id: number) => observableOf(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockBitstreamDataService = {
|
||||||
|
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
||||||
|
return createSuccessfulRemoteDataObject$(new Bitstream());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [NoopAnimationsModule],
|
imports: [NoopAnimationsModule],
|
||||||
declarations: [component, TruncatePipe],
|
declarations: [component, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
{ 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]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(component, {
|
}).overrideComponent(component, {
|
||||||
|
Reference in New Issue
Block a user