From b8c99019dc136531ad3a05dab1cc80ba8e2948c5 Mon Sep 17 00:00:00 2001 From: Angelo Veltens Date: Sun, 19 Jul 2020 20:53:30 +0200 Subject: [PATCH] add failing test for JSON-LD fetching problem --- tests/unit/fetcher-jsonld-test.js | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/unit/fetcher-jsonld-test.js diff --git a/tests/unit/fetcher-jsonld-test.js b/tests/unit/fetcher-jsonld-test.js new file mode 100644 index 000000000..8ddca86af --- /dev/null +++ b/tests/unit/fetcher-jsonld-test.js @@ -0,0 +1,40 @@ +import * as rdf from '../../src'; + +const nock = require('nock') +import chai from 'chai' + +const {expect} = chai + +describe('Given a JSON-LD resource', () => { + + const uri = "http://localhost/jsonld#it" + + beforeEach(() => { + const docContents = ` + { + "@id": ${uri}, + "https://predicate.example": "value" + } + ` + nock('http://localhost').get('/jsonld').reply(200, docContents, { + 'Content-Type': 'application/ld+json', + }) + }); + + describe('when it is fetched to the store', () => { + + let fetcher, store; + beforeEach(() => { + store = rdf.graph(); + fetcher = rdf.fetcher(store); + }); + + it('then the triples from the document can be found in the store', async () => { + await fetcher.load(uri); + const match = store.anyStatementMatching(rdf.sym(uri)) + expect(match).to.be.ok() + }); + }); + + +}); \ No newline at end of file