Skip to content

Commit 20ff386

Browse files
94481: Fixed tests
1 parent a4b9a6d commit 20ff386

6 files changed

Lines changed: 20 additions & 21 deletions

File tree

src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/org-unit/org-unit-sidebar-search-list-element.component.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const object = Object.assign(new ItemSearchResult(), {
88
indexableObject: Object.assign(new Item(), {
99
id: 'test-item',
1010
metadata: {
11+
'dspace.entity.type': [
12+
{
13+
value: 'OrgUnit'
14+
}
15+
],
1116
'organization.legalName': [
1217
{
1318
value: 'title'

src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/person/person-sidebar-search-list-element.component.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import { Collection } from '../../../../../core/shared/collection.model';
33
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
44
import { createSidebarSearchListElementTests } from '../../../../../shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.spec';
55
import { PersonSidebarSearchListElementComponent } from './person-sidebar-search-list-element.component';
6-
import { TranslateService } from '@ngx-translate/core';
76

87
const object = Object.assign(new ItemSearchResult(), {
98
indexableObject: Object.assign(new Item(), {
109
id: 'test-item',
1110
metadata: {
11+
'dspace.entity.type': [
12+
{
13+
value: 'Person',
14+
}
15+
],
1216
'person.familyName': [
1317
{
1418
value: 'family name'
@@ -40,6 +44,5 @@ const parent = Object.assign(new Collection(), {
4044

4145
describe('PersonSidebarSearchListElementComponent',
4246
createSidebarSearchListElementTests(PersonSidebarSearchListElementComponent, object, parent, 'parent title', 'family name, given name', 'job title', [
43-
{ provide: TranslateService, useValue: jasmine.createSpyObj('translate', { instant: '' }) }
4447
])
4548
);

src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils
2424
import { TruncatableService } from '../../../../truncatable/truncatable.service';
2525
import { TruncatePipe } from '../../../../utils/truncate.pipe';
2626
import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component';
27+
import { TranslateModule } from '@ngx-translate/core';
2728

2829
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
2930
mockItemWithMetadata.hitHighlights = {};
@@ -99,7 +100,10 @@ export function getEntityGridElementTestComponent(component, searchResultWithMet
99100

100101
beforeEach(waitForAsync(() => {
101102
TestBed.configureTestingModule({
102-
imports: [NoopAnimationsModule],
103+
imports: [
104+
NoopAnimationsModule,
105+
TranslateModule.forRoot(),
106+
],
103107
declarations: [component, TruncatePipe],
104108
providers: [
105109
{ provide: TruncatableService, useValue: truncatableServiceStub },

src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<div [ngClass]="isCurrent() ? 'text-light' : 'text-body'"
33
[innerHTML]="(parentTitle$ && parentTitle$ | async) ? (parentTitle$ | async) : ('home.breadcrumbs' | translate)"></div>
44
</ds-truncatable-part>
5-
<ds-truncatable-part *ngIf="title" [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
5+
<ds-truncatable-part [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
66
<div class="font-weight-bold"
77
[ngClass]="isCurrent() ? 'text-light' : 'text-primary'"
8-
[innerHTML]="title"></div>
8+
[innerHTML]="dsoTitle"></div>
99
</ds-truncatable-part>
1010
<ds-truncatable-part *ngIf="description" [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'">
1111
<div class="text-secondary"

src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function createSidebarSearchListElementTests(
4040
providers: [
4141
{ provide: TruncatableService, useValue: {} },
4242
{ provide: LinkService, useValue: linkService },
43-
{ provide: DSONameService, useClass: DSONameServiceMock },
43+
DSONameService,
4444
...extraProviders
4545
],
4646
schemas: [NO_ERRORS_SCHEMA]
@@ -51,6 +51,7 @@ export function createSidebarSearchListElementTests(
5151
fixture = TestBed.createComponent(componentClass);
5252
component = fixture.componentInstance;
5353
component.object = object;
54+
component.ngOnInit();
5455
fixture.detectChanges();
5556
});
5657

@@ -62,7 +63,7 @@ export function createSidebarSearchListElementTests(
6263
});
6364

6465
it('should contain the correct title', () => {
65-
expect(component.title).toEqual(expectedTitle);
66+
expect(component.dsoTitle).toEqual(expectedTitle);
6667
});
6768

6869
it('should contain the correct description', () => {

src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ export class SidebarSearchListElementComponent<T extends SearchResult<K>, K exte
2828
*/
2929
parentTitle$: Observable<string>;
3030

31-
/**
32-
* The title for the object to display
33-
*/
34-
title: string;
35-
3631
/**
3732
* A description to display below the title
3833
*/
@@ -52,7 +47,6 @@ export class SidebarSearchListElementComponent<T extends SearchResult<K>, K exte
5247
super.ngOnInit();
5348
if (hasValue(this.dso)) {
5449
this.parentTitle$ = this.getParentTitle();
55-
this.title = this.getTitle();
5650
this.description = this.getDescription();
5751
}
5852
}
@@ -89,14 +83,6 @@ export class SidebarSearchListElementComponent<T extends SearchResult<K>, K exte
8983
return observableOf(undefined);
9084
}
9185

92-
/**
93-
* Get the title of the object
94-
* Default: defined by {@link DSONameService}
95-
*/
96-
getTitle(): string {
97-
return this.dsoNameService.getName(this.dso);
98-
}
99-
10086
/**
10187
* Get the description of the object
10288
* Default: "(dc.publisher, dc.date.issued) authors"

0 commit comments

Comments
 (0)