diff --git a/lib/catalog.js b/lib/catalog.js index a24638af925c5127bd3fbdc8d7e96bf67beda37d..c9f509df654d6ae58c983bc0c395f466784e8d9a 100644 --- a/lib/catalog.js +++ b/lib/catalog.js @@ -162,9 +162,7 @@ async function datapub2catalog(options) { if( items ) { const eitems = items.filter((i) => i); if( eitems ) { - dataset[property] = items.map((i) => { - return { '@id': i['@id'] } - }); + dataset[property] = items.map(link_id); graph.push(eitems); } } @@ -205,7 +203,7 @@ function make_dataset(id, datapub, organisation, dates, files) { 'description': datapub['description'], 'dateCreated': dates['dateCreated'], 'datePublished': dates['datePublished'], - 'Publisher': link_id(organisation), + 'publisher': link_id(organisation), 'hasPart': files.map(link_id), }; return ds; diff --git a/test/catalog.spec.js b/test/catalog.spec.js index 6901357a5a04a6cb267ca5925b6b956e300dda9e..e57ba954cc233b197b96eca60b21fc926835c206 100644 --- a/test/catalog.spec.js +++ b/test/catalog.spec.js @@ -48,30 +48,36 @@ function graph_get(graph, id) { } } +var dp, cj; -describe("ReDBox data publication to DataCrate catalog.json", () => { +describe("DataPub to DataCrate: core metadata", () => { - it("returns a catalog with a dataset item", async () => { - const dp = await fs.readJson('./test_data/datapub.json'); - const cj = await catalog.datapub2catalog({ + before(async () => { + dp = await fs.readJson('./test_data/datapub.json'); + cj = await catalog.datapub2catalog({ 'id': DATASET_ID, 'datapub': dp, 'organisation': ORG, 'owner': OWNER, 'approver': APPROVER - }); + }); + }); + + + it("puts a dataset item with correct metadata in the catalog", async () => { assert(cj, "Got an object"); assert(cj['@graph'], "Catalog has a @graph"); const dataset = graph_get(cj['@graph'], DATASET_ID); assert(dataset, "Graph has an item with id " + DATASET_ID); expect(dataset['name']).to.equal(dp['title']); expect(dataset['description']).to.equal(dp['description']); + expect(dataset['publisher']['@id']).to.equal(ORG['id']); }); - it("Can set dateCreated and datePublished", async() => { + it("has a history section with the owner and approver", async () => { assert(true); - }) + }); });