Skip to content

Commit

Permalink
Add canonicalIdMap test.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlehn committed May 19, 2023
1 parent 5bae7e7 commit 09984ab
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,29 @@ describe.only('API tests', () => {
}
assert(error);
});

it('should return maps', async () => {
const input = `\
_:b0 <urn:p0> _:b1 .
_:b1 <urn:p1> "v1" .
`;
const expected = `\
_:c14n0 <urn:p0> _:c14n1 .
_:c14n1 <urn:p1> "v1" .
`;
const expectIdMap = new Map(Object.entries({
"_:b0": "_:c14n0",
"_:b1": "_:c14n1"
}));

const canonicalIdMap = new Map();
const output = await rdfCanonize.canonize(input, {
algorithm: 'URDNA2015',
inputFormat: 'application/n-quads',
format: 'application/n-quads',
canonicalIdMap
});
assert.deepStrictEqual(output, expected);
assert.deepStrictEqual(canonicalIdMap, expectIdMap);
});
});

0 comments on commit 09984ab

Please sign in to comment.