From 8635de5399ff8af331a167233282c975b8cd7c44 Mon Sep 17 00:00:00 2001 From: Caleb Pomar Date: Thu, 27 Jan 2022 09:44:58 -0700 Subject: [PATCH] return default value of contactPoint['@type'] when overwritten --- CHANGELOG.md | 4 ++++ src/dcat-us/dataset-formatter.ts | 2 +- src/dcat-us/index.test.ts | 5 ++++- src/index.test.ts | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cd88bf..8ca389b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG.md +## Unreleased +Fixed +- Default value is returned when custom config attempts to overwrite contactPoint['@type'] [#17](https://github.com/koopjs/koop-output-dcat-us-11/pull/17) + ## 1.5.0 Added - Handling of path hierarchies/fallback values [#16](https://github.com/koopjs/koop-output-dcat-us-11/pull/16) diff --git a/src/dcat-us/dataset-formatter.ts b/src/dcat-us/dataset-formatter.ts index 7bab3a3..87a0974 100644 --- a/src/dcat-us/dataset-formatter.ts +++ b/src/dcat-us/dataset-formatter.ts @@ -82,7 +82,7 @@ function scrubProtectedKeys (customizations: DcatDatasetTemplate): DcatDatasetTe delete scrubbedCustomizations.landingPage; delete scrubbedCustomizations.webService; if (scrubbedCustomizations.contactPoint) { - delete scrubbedCustomizations.contactPoint['@type']; + scrubbedCustomizations.contactPoint['@type'] = 'vcard:Contact'; } delete scrubbedCustomizations.distribution; } diff --git a/src/dcat-us/index.test.ts b/src/dcat-us/index.test.ts index e98cb4d..21263f5 100644 --- a/src/dcat-us/index.test.ts +++ b/src/dcat-us/index.test.ts @@ -123,7 +123,10 @@ describe('generating DCAT-US 1.1 feed', () => { expect(chk1.issued).toBe('2021-01-29T15:34:38.000Z'); expect(chk1.modified).toBe('2021-07-27T20:25:19.723Z'); expect(chk1.publisher).toEqual({ name: 'QA Premium Alpha Hub' }); - expect(chk1.contactPoint).toEqual({ fn: 'thervey_qa_pre_a_hub' }); + expect(chk1.contactPoint).toEqual({ + "@type": "vcard:Contact", + fn: 'thervey_qa_pre_a_hub' + }); expect(chk1.accessLevel).toBe('public'); expect(chk1.spatial).toBe('-121.118,38.7754,-119.009,39.359'); expect(chk1.theme).toEqual(['geospatial']); diff --git a/src/index.test.ts b/src/index.test.ts index 33a1e2b..e83f2b7 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -289,7 +289,7 @@ describe('Output Plugin', () => { describe('configuration via query params', () => { let mockGetDataStreamDcatUs11; - beforeAll(() => { + beforeEach(() => { const { getDataStreamDcatUs11 } = require('./dcat-us'); jest.mock('./dcat-us'); mockGetDataStreamDcatUs11 = mocked(getDataStreamDcatUs11) @@ -318,6 +318,7 @@ describe('Output Plugin', () => { } } mockFetchSite.mockResolvedValue(customConfigSiteModel); + [plugin, app] = buildPluginAndApp(); await request(app) .get('/dcat')