Skip to content

Commit 3ba78b7

Browse files
committed
feat: fix unit
1 parent 1cb962b commit 3ba78b7

6 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ describe('ComColFormComponent', () => {
132132
describe('onSubmit', () => {
133133
beforeEach(() => {
134134
spyOn(comp.submitForm, 'emit');
135-
comp.formModel = formModel;
135+
comp.formModels.set('en', formModel);
136136
});
137137

138138
it('should emit the new version of the community', () => {
@@ -145,15 +145,15 @@ describe('ComColFormComponent', () => {
145145
path: '/metadata/dc.title',
146146
value: {
147147
value: 'New Community Title',
148-
language: null,
148+
language: 'en_US',
149149
},
150150
},
151151
{
152152
op: 'replace',
153153
path: '/metadata/dc.description.abstract',
154154
value: {
155155
value: 'Community description',
156-
language: null,
156+
language: 'en_US',
157157
},
158158
},
159159
];
@@ -164,11 +164,11 @@ describe('ComColFormComponent', () => {
164164
metadata: {
165165
'dc.title': [{
166166
value: 'New Community Title',
167-
language: null,
167+
language: 'en_US',
168168
}],
169169
'dc.description.abstract': [{
170170
value: 'Community description',
171-
language: null,
171+
language: 'en_US',
172172
}],
173173
},
174174
type: Community.type,
@@ -314,7 +314,6 @@ describe('ComColFormComponent', () => {
314314
function initComponent(dso: Community) {
315315
fixture = TestBed.createComponent(ComColFormComponent);
316316
comp = fixture.componentInstance;
317-
comp.formModel = [];
318317
comp.dso = dso;
319318
(comp as any).type = Community.type;
320319
comp.uploaderComponent = { uploader: {} } as any;

src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
158158
/**
159159
* All languages used by application
160160
*/
161-
languages: LangConfig[];
161+
languages: LangConfig[] = [];
162162

163163
/**
164164
* The uploader configuration options

src/app/shared/mocks/translate.service.mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export function getMockTranslateService(): TranslateService {
66
use: jasmine.createSpy('use'),
77
instant: jasmine.createSpy('instant'),
88
setDefaultLang: jasmine.createSpy('setDefaultLang'),
9+
currentLang: 'en_US',
910
});
1011
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<ds-badges *ngIf="showLabel" [object]="dso" [context]="context"></ds-badges>
55
<a *ngIf="linkType !== linkTypes.None" [target]="(linkType === linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType === linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="['/collections/' + dso.id]" class="lead" [innerHTML]="dsoTitle"></a>
66
<span *ngIf="linkType === linkTypes.None" class="lead" [innerHTML]="dsoTitle"></span>
7-
<div *ngIf="dso.shortDescription" class="text-muted abstract-text" [innerHTML]="firstMetadataValue('dc.description.abstract')"></div>
7+
<div *ngIf="dso.shortDescription(translateService.currentLang)" class="text-muted abstract-text" [innerHTML]="firstMetadataValue('dc.description.abstract')"></div>
88
</div>
99
</div>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import {
1010
} from '@angular/core/testing';
1111
import { By } from '@angular/platform-browser';
1212
import { ActivatedRoute } from '@angular/router';
13+
import { TranslateService } from '@ngx-translate/core';
1314
import { of as observableOf } from 'rxjs';
1415

1516
import { APP_CONFIG } from '../../../../../config/app-config.interface';
1617
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
1718
import { Collection } from '../../../../core/shared/collection.model';
1819
import { DSONameServiceMock } from '../../../mocks/dso-name.service.mock';
20+
import { getMockTranslateService } from '../../../mocks/translate.service.mock';
1921
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
2022
import { ActivatedRouteStub } from '../../../testing/active-router.stub';
2123
import { TruncatableService } from '../../../truncatable/truncatable.service';
@@ -73,6 +75,7 @@ describe('CollectionSearchResultListElementComponent', () => {
7375
{ provide: APP_CONFIG, useValue: environmentUseThumbs },
7476
{ provide: ActivatedRoute, useValue: new ActivatedRouteStub() },
7577
{ provide: ThemeService, useValue: getMockThemeService() },
78+
{ provide: TranslateService, useValue: getMockTranslateService() },
7679
],
7780
schemas: [NO_ERRORS_SCHEMA],
7881
}).overrideComponent(CollectionSearchResultListElementComponent, {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ import {
44
} from '@angular/common';
55
import { Component } from '@angular/core';
66
import { RouterLink } from '@angular/router';
7+
import { TranslateService } from '@ngx-translate/core';
78

9+
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
810
import { Collection } from '../../../../core/shared/collection.model';
911
import { ViewMode } from '../../../../core/shared/view-mode.model';
1012
import { ThemedBadgesComponent } from '../../../object-collection/shared/badges/themed-badges.component';
1113
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
1214
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
15+
import { TruncatableService } from '../../../truncatable/truncatable.service';
1316
import { SearchResultListElementComponent } from '../search-result-list-element.component';
1417

1518
@Component({
@@ -30,6 +33,12 @@ export class CollectionSearchResultListElementComponent extends SearchResultList
3033
*/
3134
showThumbnails: boolean;
3235

36+
constructor(protected truncatableService: TruncatableService,
37+
public dsoNameService: DSONameService,
38+
public translateService: TranslateService) {
39+
super(truncatableService, dsoNameService);
40+
}
41+
3342
ngOnInit(): void {
3443
super.ngOnInit();
3544
this.showThumbnails = this.showThumbnails ?? this.appConfig.browseBy.showThumbnails;

0 commit comments

Comments
 (0)