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', () => {