Skip to content
Snippets Groups Projects
Commit 9b3b277d authored by Mike Lynch's avatar Mike Lynch
Browse files

refactored the tests so that the datapub and catalog.json are generated

in a before() clause
parent 3dbf788f
Branches
No related merge requests found
......@@ -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;
......
......@@ -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);
})
});
});
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment