From 7b17f9443d26b2cef1ae0ec6a54083fc5bc86af0 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Wed, 15 Apr 2020 02:50:43 -0400 Subject: [PATCH] Add various list + base tests. --- tests/misc.js | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/tests/misc.js b/tests/misc.js index 1c3758e0..fee46bf1 100644 --- a/tests/misc.js +++ b/tests/misc.js @@ -159,6 +159,150 @@ describe('other toRDF tests', () => { done(); }); }); + + it.only('should handle list good @context @base', async () => { + const doc = { + "@context": { + "@base": "ex:", + "list": { + "@id": "foo:bar", + "@container": "@list", + "@type": "@id" + } + }, + "list": [ + "test" + ] + }; + const rdf = await jsonld.toRDF(doc, { + format: 'application/n-quads' + }); + assert.equal( + rdf, + '_:b0 _:b1 .\n' + + '_:b1 .\n' + + '_:b1 .\n'); + }); + + it.only('should handle list bad @context @base', async () => { + const doc = { + "@context": { + "@base": "::", + "list": { + "@id": "foo:bar", + "@container": "@list", + "@type": "@id" + } + }, + "list": [ + "test" + ] + }; + const rdf = await jsonld.toRDF(doc, { + format: 'application/n-quads' + }); + assert.equal( + rdf, + '_:b0 _:b1 .\n' + + //'_:b1 .\n' + + '_:b1 .\n'); + }); + + it.only('should handle list empty base option', async () => { + const doc = { + "@context": { + "list": { + "@id": "foo:bar", + "@container": "@list", + "@type": "@id" + } + }, + "list": [ + "test" + ] + }; + const rdf = await jsonld.toRDF(doc, { + base: '', + format: 'application/n-quads' + }); + assert.equal( + rdf, + '_:b0 _:b1 .\n' + + //'_:b1 .\n' + + '_:b1 .\n'); + }); + + it.only('should handle list null base option', async () => { + const doc = { + "@context": { + "list": { + "@id": "foo:bar", + "@container": "@list", + "@type": "@id" + } + }, + "list": [ + "test" + ] + }; + const rdf = await jsonld.toRDF(doc, { + base: null, + format: 'application/n-quads' + }); + assert.equal( + rdf, + '_:b0 _:b1 .\n' + + //'_:b1 .\n' + + '_:b1 .\n'); + }); + + it.only('should handle list empty @context @base', async () => { + const doc = { + "@context": { + "@base": "", + "list": { + "@id": "foo:bar", + "@container": "@list", + "@type": "@id" + } + }, + "list": [ + "test" + ] + }; + const rdf = await jsonld.toRDF(doc, { + format: 'application/n-quads' + }); + assert.equal( + rdf, + '_:b0 _:b1 .\n' + + //'_:b1 .\n' + + '_:b1 .\n'); + }); + + it.only('should handle list null @context @base', async () => { + const doc = { + "@context": { + "@base": null, + "list": { + "@id": "foo:bar", + "@container": "@list", + "@type": "@id" + } + }, + "list": [ + "test" + ] + }; + const rdf = await jsonld.toRDF(doc, { + format: 'application/n-quads' + }); + assert.equal( + rdf, + '_:b0 _:b1 .\n' + + //'_:b1 .\n' + + '_:b1 .\n'); + }); }); describe('other fromRDF tests', () => {