Skip to content

Commit 2af9984

Browse files
committed
repair tests
1 parent 7771cff commit 2af9984

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/app/item-page/field-components/metadata-values/metadata-values.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ds-metadata-field-wrapper [label]="label | translate">
22
<ng-container *ngFor="let mdValue of mdValues; let last=last;">
3-
<ng-container *ngTemplateOutlet="(env.markdown.enabled && this.enableMarkdown ? markdown : simple); context: {value: mdValue.value, classes: 'dont-break-out preserve-line-breaks'}">
3+
<ng-container *ngTemplateOutlet="(renderMarkdown ? markdown : simple); context: {value: mdValue.value, classes: 'dont-break-out preserve-line-breaks'}">
44
</ng-container>
55
<span class="separator" *ngIf="!last" [innerHTML]="separator"></span>
66
</ng-container>

src/app/item-page/field-components/metadata-values/metadata-values.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input } from '@angular/core';
1+
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
22
import { MetadataValue } from '../../../core/shared/metadata.models';
33
import { environment } from '../../../../environments/environment';
44

@@ -11,7 +11,7 @@ import { environment } from '../../../../environments/environment';
1111
styleUrls: ['./metadata-values.component.scss'],
1212
templateUrl: './metadata-values.component.html'
1313
})
14-
export class MetadataValuesComponent {
14+
export class MetadataValuesComponent implements OnChanges {
1515

1616
/**
1717
* The metadata values to display
@@ -35,5 +35,12 @@ export class MetadataValuesComponent {
3535
*/
3636
@Input() enableMarkdown = false;
3737

38-
env = environment;
38+
/**
39+
* This variable will be true if both {@link environment.markdown.enabled} and {@link enableMarkdown} are true.
40+
*/
41+
renderMarkdown;
42+
43+
ngOnChanges(changes: SimpleChanges): void {
44+
this.renderMarkdown = !!environment.markdown.enabled && this.enableMarkdown;
45+
}
3946
}

src/app/item-page/simple/field-components/specific-field/item-page-field.component.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { createPaginatedList } from '../../../../shared/testing/utils.test';
1111
import { environment } from '../../../../../environments/environment';
1212
import { MarkdownPipe } from '../../../../shared/utils/markdown.pipe';
1313
import { SharedModule } from '../../../../shared/shared.module';
14+
import { APP_CONFIG } from '../../../../../config/app-config.interface';
1415

1516
let comp: ItemPageFieldComponent;
1617
let fixture: ComponentFixture<ItemPageFieldComponent>;
@@ -33,6 +34,9 @@ describe('ItemPageFieldComponent', () => {
3334
}),
3435
SharedModule,
3536
],
37+
providers: [
38+
{ provide: APP_CONFIG, useValue: Object.assign({}, environment) },
39+
],
3640
declarations: [ItemPageFieldComponent, MetadataValuesComponent],
3741
schemas: [NO_ERRORS_SCHEMA]
3842
}).overrideComponent(ItemPageFieldComponent, {
@@ -57,7 +61,7 @@ describe('ItemPageFieldComponent', () => {
5761
describe('when markdown is disabled in the environment config', () => {
5862

5963
beforeEach(() => {
60-
environment.markdown.enabled = false;
64+
TestBed.inject(APP_CONFIG).markdown.enabled = false;
6165
});
6266

6367
describe('and markdown is disabled in this component', () => {
@@ -88,7 +92,7 @@ describe('ItemPageFieldComponent', () => {
8892
describe('when markdown is enabled in the environment config', () => {
8993

9094
beforeEach(() => {
91-
environment.markdown.enabled = true;
95+
TestBed.inject(APP_CONFIG).markdown.enabled = true;
9296
});
9397

9498
describe('and markdown is disabled in this component', () => {

0 commit comments

Comments
 (0)