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

Fixed the existing tests so that they will behave correctly if the fields

they are testing for are not defined on the input data pub
parent 7687e053
Branches
Tags v1.0.5
No related merge requests found
......@@ -65,6 +65,10 @@ function get_type(c, t) {
var mdp, dp, cj, cjds;
// TODO: it would be great if these could be run against a
// range of different test datapubs which didn't have all of
// the values
describe("Convert a ReDBox 2.0 DataPub to CATALOG.json", () => {
before(async () => {
......@@ -101,8 +105,10 @@ describe("Convert a ReDBox 2.0 DataPub to CATALOG.json", () => {
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'])
expect(dataset['keywords']).to.equal(dp['finalKeywords'].join(', '));
expect(dataset['publisher']['@id']).to.equal(ORG['id']);
if( dp['finalKeywords']) {
expect(dataset['keywords']).to.equal(dp['finalKeywords'].join(', '));
}
});
it("has a create action with the owner", () => {
......@@ -142,7 +148,11 @@ describe("Convert a ReDBox 2.0 DataPub to CATALOG.json", () => {
const expectsubs = dp[field].map((f) => { return f['name'] });
const subjects = cj['@graph'].filter((i) => { return i['@id'].startsWith(pref) });
const gotsubs = subjects.map((f) => { return f['name']} );
expect(gotsubs.sort()).to.eql(expectsubs.sort());
if( dp[field] && dp[field].length > 0 ) {
expect(gotsubs.sort()).to.eql(expectsubs.sort());
} else {
expect(gotsubs).to.be.empty;
}
})
});
......
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