Skip to content

Commit

Permalink
Merge pull request #10 from koopjs/f/7037-add-links
Browse files Browse the repository at this point in the history
add ogc links under properties
  • Loading branch information
sansth1010 authored Oct 4, 2024
2 parents 3c25e94 + c1e7feb commit 97d4795
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/helpers/enrich-dataset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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'
}
])
});
})
3 changes: 3 additions & 0 deletions src/helpers/enrich-dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export function enrichDataset(dataset: Record<string, any>, siteDetails: Record<
...additionalFields
};

// template require links
dataset.properties.links = dataset.links;

return dataset;
};

Expand Down

0 comments on commit 97d4795

Please # to comment.