mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
94481: Fixed tests
This commit is contained in:
@@ -8,6 +8,11 @@ const object = Object.assign(new ItemSearchResult(), {
|
|||||||
indexableObject: Object.assign(new Item(), {
|
indexableObject: Object.assign(new Item(), {
|
||||||
id: 'test-item',
|
id: 'test-item',
|
||||||
metadata: {
|
metadata: {
|
||||||
|
'dspace.entity.type': [
|
||||||
|
{
|
||||||
|
value: 'OrgUnit'
|
||||||
|
}
|
||||||
|
],
|
||||||
'organization.legalName': [
|
'organization.legalName': [
|
||||||
{
|
{
|
||||||
value: 'title'
|
value: 'title'
|
||||||
|
@@ -3,12 +3,16 @@ import { Collection } from '../../../../../core/shared/collection.model';
|
|||||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
import { createSidebarSearchListElementTests } from '../../../../../shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.spec';
|
import { createSidebarSearchListElementTests } from '../../../../../shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.spec';
|
||||||
import { PersonSidebarSearchListElementComponent } from './person-sidebar-search-list-element.component';
|
import { PersonSidebarSearchListElementComponent } from './person-sidebar-search-list-element.component';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
|
|
||||||
const object = Object.assign(new ItemSearchResult(), {
|
const object = Object.assign(new ItemSearchResult(), {
|
||||||
indexableObject: Object.assign(new Item(), {
|
indexableObject: Object.assign(new Item(), {
|
||||||
id: 'test-item',
|
id: 'test-item',
|
||||||
metadata: {
|
metadata: {
|
||||||
|
'dspace.entity.type': [
|
||||||
|
{
|
||||||
|
value: 'Person',
|
||||||
|
}
|
||||||
|
],
|
||||||
'person.familyName': [
|
'person.familyName': [
|
||||||
{
|
{
|
||||||
value: 'family name'
|
value: 'family name'
|
||||||
@@ -40,6 +44,5 @@ const parent = Object.assign(new Collection(), {
|
|||||||
|
|
||||||
describe('PersonSidebarSearchListElementComponent',
|
describe('PersonSidebarSearchListElementComponent',
|
||||||
createSidebarSearchListElementTests(PersonSidebarSearchListElementComponent, object, parent, 'parent title', 'family name, given name', 'job title', [
|
createSidebarSearchListElementTests(PersonSidebarSearchListElementComponent, object, parent, 'parent title', 'family name, given name', 'job title', [
|
||||||
{ provide: TranslateService, useValue: jasmine.createSpyObj('translate', { instant: '' }) }
|
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
@@ -24,6 +24,7 @@ import { createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils
|
|||||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||||
import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component';
|
import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
mockItemWithMetadata.hitHighlights = {};
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
@@ -99,7 +100,10 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet
|
|||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [NoopAnimationsModule],
|
imports: [
|
||||||
|
NoopAnimationsModule,
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
],
|
||||||
declarations: [component, TruncatePipe],
|
declarations: [component, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||||
|
@@ -2,10 +2,10 @@
|
|||||||
<div [ngClass]="isCurrent() ? 'text-light' : 'text-body'"
|
<div [ngClass]="isCurrent() ? 'text-light' : 'text-body'"
|
||||||
[innerHTML]="(parentTitle$ && parentTitle$ | async) ? (parentTitle$ | async) : ('home.breadcrumbs' | translate)"></div>
|
[innerHTML]="(parentTitle$ && parentTitle$ | async) ? (parentTitle$ | async) : ('home.breadcrumbs' | translate)"></div>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
<ds-truncatable-part *ngIf="title" [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
|
<ds-truncatable-part [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
|
||||||
<div class="font-weight-bold"
|
<div class="font-weight-bold"
|
||||||
[ngClass]="isCurrent() ? 'text-light' : 'text-primary'"
|
[ngClass]="isCurrent() ? 'text-light' : 'text-primary'"
|
||||||
[innerHTML]="title"></div>
|
[innerHTML]="dsoTitle"></div>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
<ds-truncatable-part *ngIf="description" [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
|
<ds-truncatable-part *ngIf="description" [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
|
||||||
<div class="text-secondary"
|
<div class="text-secondary"
|
||||||
|
@@ -40,7 +40,7 @@ export function createSidebarSearchListElementTests(
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: {} },
|
{ provide: TruncatableService, useValue: {} },
|
||||||
{ provide: LinkService, useValue: linkService },
|
{ provide: LinkService, useValue: linkService },
|
||||||
{ provide: DSONameService, useClass: DSONameServiceMock },
|
DSONameService,
|
||||||
...extraProviders
|
...extraProviders
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
@@ -51,6 +51,7 @@ export function createSidebarSearchListElementTests(
|
|||||||
fixture = TestBed.createComponent(componentClass);
|
fixture = TestBed.createComponent(componentClass);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.object = object;
|
component.object = object;
|
||||||
|
component.ngOnInit();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ export function createSidebarSearchListElementTests(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the correct title', () => {
|
it('should contain the correct title', () => {
|
||||||
expect(component.title).toEqual(expectedTitle);
|
expect(component.dsoTitle).toEqual(expectedTitle);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain the correct description', () => {
|
it('should contain the correct description', () => {
|
||||||
|
@@ -28,11 +28,6 @@ export class SidebarSearchListElementComponent<T extends SearchResult<K>, K exte
|
|||||||
*/
|
*/
|
||||||
parentTitle$: Observable<string>;
|
parentTitle$: Observable<string>;
|
||||||
|
|
||||||
/**
|
|
||||||
* The title for the object to display
|
|
||||||
*/
|
|
||||||
title: string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A description to display below the title
|
* A description to display below the title
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +47,6 @@ export class SidebarSearchListElementComponent<T extends SearchResult<K>, K exte
|
|||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
if (hasValue(this.dso)) {
|
if (hasValue(this.dso)) {
|
||||||
this.parentTitle$ = this.getParentTitle();
|
this.parentTitle$ = this.getParentTitle();
|
||||||
this.title = this.getTitle();
|
|
||||||
this.description = this.getDescription();
|
this.description = this.getDescription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,14 +83,6 @@ export class SidebarSearchListElementComponent<T extends SearchResult<K>, K exte
|
|||||||
return observableOf(undefined);
|
return observableOf(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the title of the object
|
|
||||||
* Default: defined by {@link DSONameService}
|
|
||||||
*/
|
|
||||||
getTitle(): string {
|
|
||||||
return this.dsoNameService.getName(this.dso);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the description of the object
|
* Get the description of the object
|
||||||
* Default: "(dc.publisher, dc.date.issued) authors"
|
* Default: "(dc.publisher, dc.date.issued) authors"
|
||||||
|
Reference in New Issue
Block a user