diff --git a/src/helpers/enrich-dataset.test.ts b/src/helpers/enrich-dataset.test.ts index 760b816..64ed567 100644 --- a/src/helpers/enrich-dataset.test.ts +++ b/src/helpers/enrich-dataset.test.ts @@ -75,6 +75,7 @@ describe('enrichDataset function', () => { agoLandingPage: 'portal.arcgis.com/home/item.html?id=123a&sublayer=0', isLayer: true, license: '', + links: undefined } const geojson = { @@ -501,4 +502,52 @@ describe('enrichDataset function', () => { expect(properties).toBeDefined() expect(properties.issuedDateTime).toBeUndefined() }); + + it('should add links to geojson properties', () => { + const hubDataset = { + id: 'foo', + access: 'public', + size: 1, + type: 'CSV', + created: 'invalid-string' + }; + + const geojson = { + type: 'Feature', + properties: hubDataset, + links: [ + { + rel: 'external', + type: 'csv', + title: 'csv', + href: 'https://download-url/csv' + }, + { + rel: 'external', + type: 'geojson', + title: 'geojson', + href: 'https://download-url/geojson' + } + ] + } + + const { properties } = enrichDataset(geojson, + { siteUrl: 'arcgis.com', portalUrl: 'portal.com', orgBaseUrl: 'qa.arcgis.com', orgTitle: "QA Premium Alpha Hub" }); + expect(properties).toBeDefined() + expect(properties.links).toBeDefined() + expect(properties.links).toStrictEqual([ + { + rel: 'external', + type: 'csv', + title: 'csv', + href: 'https://download-url/csv' + }, + { + rel: 'external', + type: 'geojson', + title: 'geojson', + href: 'https://download-url/geojson' + } + ]) + }); }) \ No newline at end of file diff --git a/src/helpers/enrich-dataset.ts b/src/helpers/enrich-dataset.ts index 8054b29..f7fa7b6 100644 --- a/src/helpers/enrich-dataset.ts +++ b/src/helpers/enrich-dataset.ts @@ -71,6 +71,9 @@ export function enrichDataset(dataset: Record, siteDetails: Record< ...additionalFields }; + // template require links + dataset.properties.links = dataset.links; + return dataset; };