From 758d29c998ab0ba1a04c03fc2ae2f5e6f43af500 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 4 Oct 2023 22:53:03 -0400 Subject: [PATCH] Add tests. - Add simple invalid N-Quads test. - Start of IRI escaping test. --- test/misc.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/misc.js b/test/misc.js index 7c1dee5..83cbd33 100644 --- a/test/misc.js +++ b/test/misc.js @@ -395,4 +395,44 @@ _:c14n1 _:c14n0 . assert.deepStrictEqual(output, expected); }); + it('should fail on invalid N-Quads', async () => { + const input = `\ +_:b0 . +`; + let error; + let output; + try { + output = await rdfCanonize.canonize(input, { + algorithm: 'RDFC-1.0', + inputFormat: 'application/n-quads' + }); + } catch(e) { + error = e; + } + assert(error, 'no abort error'); + assert.match(error.message, /N-Quads parse error/); + assert(!output, 'abort should have no output'); + }); + + it.skip('should escape IRI', async () => { + // FIXME: determine what inputs trigger escaping code + const input = +[ + { + subject: {termType: 'NamedNode', value: 'ex:s'}, + predicate: {termType: 'NamedNode', value: 'ex:p'}, + object: {termType: 'NamedNode', value: 'ex:o'}, + graph: {termType: 'NamedNode', value: 'ex:g'} + } +] +; + const expected = `\ + . +`; + + const output = await rdfCanonize.canonize(input, { + algorithm: 'RDFC-1.0' + }); + assert.deepStrictEqual(output, expected); + }); });