From 0c56fb5c576c30c1c589ac3bc8ad947f70f69765 Mon Sep 17 00:00:00 2001 From: Tobias Kohr Date: Fri, 17 Nov 2023 11:01:36 +0100 Subject: [PATCH] fix(metadata-info): handle updateFrequency correctly if not defined --- .../metadata-info.component.spec.ts | 16 ++++++++++++++++ .../lib/metadata-info/metadata-info.component.ts | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libs/ui/elements/src/lib/metadata-info/metadata-info.component.spec.ts b/libs/ui/elements/src/lib/metadata-info/metadata-info.component.spec.ts index effeced84f..540610eadb 100644 --- a/libs/ui/elements/src/lib/metadata-info/metadata-info.component.spec.ts +++ b/libs/ui/elements/src/lib/metadata-info/metadata-info.component.spec.ts @@ -93,6 +93,22 @@ describe('MetadataInfoComponent', () => { }) }) describe('updateFrequency', () => { + describe('updateFrequency is null', () => { + beforeEach(() => { + fixture = TestBed.createComponent(MetadataInfoComponent) + component = fixture.componentInstance + component.metadata = { + ...DATASET_RECORDS[0], + updateFrequency: null, + } + fixture.detectChanges() + }) + it('should not display the updateFrequency section', () => { + const displayedElement = + fixture.nativeElement.querySelector('.updateFrequency') + expect(displayedElement).toBeFalsy() + }) + }) describe('updateFrequency as UpdateFrequencyCode', () => { beforeEach(() => { fixture = TestBed.createComponent(MetadataInfoComponent) diff --git a/libs/ui/elements/src/lib/metadata-info/metadata-info.component.ts b/libs/ui/elements/src/lib/metadata-info/metadata-info.component.ts index 18b1990b20..f74ea4df78 100644 --- a/libs/ui/elements/src/lib/metadata-info/metadata-info.component.ts +++ b/libs/ui/elements/src/lib/metadata-info/metadata-info.component.ts @@ -42,8 +42,10 @@ export class MetadataInfoComponent { if (this.metadata.updateFrequency instanceof Object) { this.updatedTimes = this.metadata.updateFrequency.updatedTimes return `domain.record.updateFrequency.${this.metadata.updateFrequency.per}` - } else { + } else if (typeof this.metadata.updateFrequency === 'string') { return `domain.record.updateFrequency.${this.metadata.updateFrequency}` + } else { + return undefined } }