Skip to content

Commit

Permalink
fix(metadata-info): handle updateFrequency correctly if not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Nov 22, 2023
1 parent 9d30a1b commit 8a7f2df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 8a7f2df

Please sign in to comment.