From 8f4ee26611f053d63ca314d0c71bca3332a725f6 Mon Sep 17 00:00:00 2001 From: David de Boer Date: Mon, 23 Sep 2024 15:02:21 +0200 Subject: [PATCH] fix: Reconciliation API URLs --- jest.config.js | 4 ++-- .../src/getCatalog.ts | 6 ++--- .../test/catalog.test.ts | 23 +++++++++---------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/jest.config.js b/jest.config.js index 66195a4c..2af3c384 100644 --- a/jest.config.js +++ b/jest.config.js @@ -10,8 +10,8 @@ export default { ], coverageThreshold: { global: { - lines: 91.4, - statements: 91.4, + lines: 91.39, + statements: 91.39, branches: 95.46, functions: 92.62, }, diff --git a/packages/network-of-terms-catalog/src/getCatalog.ts b/packages/network-of-terms-catalog/src/getCatalog.ts index 163b317a..fc9c6cda 100644 --- a/packages/network-of-terms-catalog/src/getCatalog.ts +++ b/packages/network-of-terms-catalog/src/getCatalog.ts @@ -106,10 +106,8 @@ export async function fromStore(store: RDF.Store): Promise { bindings .get('reconciliationUrlTemplate')! .value.replace( - '{distribution}', - bindings - .get('distribution')! - .value.replace('#', '%23') // Escape # in URL. + '{dataset}', + bindings.get('dataset')!.value.replace('#', '%23') // Escape # in URL. ) ) ), diff --git a/packages/network-of-terms-catalog/test/catalog.test.ts b/packages/network-of-terms-catalog/test/catalog.test.ts index 4c4c8f5c..fc49b171 100644 --- a/packages/network-of-terms-catalog/test/catalog.test.ts +++ b/packages/network-of-terms-catalog/test/catalog.test.ts @@ -1,12 +1,11 @@ import { Catalog, Dataset, - Feature, FeatureType, IRI, SparqlDistribution, } from '@netwerk-digitaal-erfgoed/network-of-terms-query'; -import {getCatalog, fromFile, fromStore} from '../src/index.js'; +import {fromFile, fromStore, getCatalog} from '../src/index.js'; import {dirname, resolve} from 'path'; import {fileURLToPath} from 'url'; @@ -30,8 +29,8 @@ describe('Catalog', () => { catalog.getDatasetByDistributionIri(new IRI('https://nope.com')) ).toBeUndefined(); - const cht = catalog.getDatasetByDistributionIri( - new IRI('https://data.cultureelerfgoed.nl/PoolParty/sparql/term/id/cht') + const cht = catalog.getDatasetByIri( + new IRI('https://data.cultureelerfgoed.nl/term/id/cht') )!; expect(cht).toBeInstanceOf(Dataset); expect(cht.name).toEqual('Cultuurhistorische Thesaurus'); @@ -52,6 +51,12 @@ describe('Catalog', () => { 'Rijksdienst voor het Cultureel Erfgoed' ); expect(cht.creators[0].alternateName).toEqual('RCE'); + expect(cht.distributions[0].features[0].type).toEqual( + FeatureType.RECONCILIATION + ); + expect(cht.distributions[0].features[0].url.toString()).toEqual( + `https://termennetwerk-api.netwerkdigitaalerfgoed.nl/reconcile/${cht.iri}` + ); }); it('can retrieve distributions by IRI', () => { @@ -84,14 +89,8 @@ describe('Catalog', () => { const reconciliationApis = catalog.getDistributionsProvidingFeature( FeatureType.RECONCILIATION ); - expect(reconciliationApis[0].features).toContainEqual( - new Feature( - FeatureType.RECONCILIATION, - new URL( - 'https://termennetwerk-api.netwerkdigitaalerfgoed.nl/reconcile/' + - reconciliationApis[0].iri.toString().replace('#', '%23') - ) - ) + expect(reconciliationApis[0].features[0].type).toEqual( + FeatureType.RECONCILIATION ); });