From bc0b64ef1198420c2821d98f9baaa5012d588dc0 Mon Sep 17 00:00:00 2001 From: tpluscode Date: Thu, 16 Jul 2020 09:54:55 +0200 Subject: [PATCH 1/7] feat: graph traversals --- lib/Clownface.js | 16 ++++++++++ lib/Context.js | 9 ++++-- test/Clownface/fromGraph.js | 59 +++++++++++++++++++++++++++++++++++++ test/Clownface/index.js | 1 + 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 test/Clownface/fromGraph.js diff --git a/lib/Clownface.js b/lib/Clownface.js index fd11e77..d6f3428 100644 --- a/lib/Clownface.js +++ b/lib/Clownface.js @@ -421,6 +421,22 @@ class Clownface { return this } + fromGraph (graph) { + if (typeof graph === 'undefined') { + throw new Error('graph parameter is required') + } + + const context = this._context.map(context => context.clone({ + graph: graph === null ? undefined : graph + })) + + return Clownface.fromContext(context) + } + + get defaultGraph () { + return rdf.defaultGraphInstance + } + _toTermArray (predicates, type, languageOrDatatype) { return toTermArray(predicates, type, languageOrDatatype, this.factory) } diff --git a/lib/Context.js b/lib/Context.js index 5db9e70..07ab298 100644 --- a/lib/Context.js +++ b/lib/Context.js @@ -12,8 +12,13 @@ class Context { this.term = term(value, undefined, undefined, factory) } - clone ({ dataset = this.dataset, graph = this.graph, value, factory = this.factory, namespace = this.namespace }) { - return new Context({ dataset, graph, value, factory, namespace }) + clone ({ dataset = this.dataset, graph, value, factory = this.factory, namespace = this.namespace }) { + let g = graph + if (typeof graph === 'undefined') { + g = undefined + } + + return new Context({ dataset, graph: g, value, factory, namespace }) } has (predicate, object) { diff --git a/test/Clownface/fromGraph.js b/test/Clownface/fromGraph.js new file mode 100644 index 0000000..b6b9fd8 --- /dev/null +++ b/test/Clownface/fromGraph.js @@ -0,0 +1,59 @@ +/* global describe, it */ + +const assert = require('assert') +const { rdfs } = require('@tpluscode/rdf-ns-builders') +const clownface = require('../..') +const rdf = require('../support/factory') +const ns = require('../support/namespace') + +describe('fromGraph', () => { + it('called with graph changes context to same term in named graph', () => { + const term = ns.ex.Foo + const dataset = rdf.dataset([ + rdf.quad(term, rdfs.label, rdf.literal('default graph')), + rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) + ]) + const pointer = clownface({ dataset, term }) + + const movedPointer = pointer.fromGraph(ns.ex.NamedGraph) + + assert.deepStrictEqual(movedPointer.out(rdfs.label).value, 'named graph') + }) + + it('called with null changes context to same term across all graphs', () => { + const term = ns.ex.Foo + const dataset = rdf.dataset([ + rdf.quad(term, rdfs.label, rdf.literal('default graph')), + rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) + ]) + const pointer = clownface({ dataset, term, graph: ns.ex.NamedGraph }) + + const movedPointer = pointer.fromGraph(null) + + assert.deepStrictEqual(movedPointer.out(rdfs.label).values.length, 2) + }) + + it('called with undefined should throw', () => { + const term = ns.ex.Foo + const dataset = rdf.dataset([ + rdf.quad(term, rdfs.label, rdf.literal('default graph')), + rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) + ]) + const pointer = clownface({ dataset, term }) + + assert.throws(() => pointer.fromGraph(undefined)) + }) + + it('called with default graph instance changes context to same term in default graph', () => { + const term = ns.ex.Foo + const dataset = rdf.dataset([ + rdf.quad(term, rdfs.label, rdf.literal('default graph')), + rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) + ]) + const pointer = clownface({ dataset, term }) + + const movedPointer = pointer.fromGraph(rdf.defaultGraphInstance) + + assert.deepStrictEqual(movedPointer.out(rdfs.label).value, 'default graph') + }) +}) diff --git a/test/Clownface/index.js b/test/Clownface/index.js index 3dff800..d8e7a32 100644 --- a/test/Clownface/index.js +++ b/test/Clownface/index.js @@ -28,4 +28,5 @@ describe('Clownface', () => { require('./deleteIn') require('./deleteOut') require('./deleteList') + require('./fromGraph') }) From 1ce25d511a77859af58c6f225173462f4bf77af5 Mon Sep 17 00:00:00 2001 From: tpluscode Date: Thu, 16 Jul 2020 14:11:28 +0200 Subject: [PATCH 2/7] test: add simple test for defaultGraph --- test/Clownface/defaultGraph.js | 15 +++++++++++++++ test/Clownface/index.js | 1 + 2 files changed, 16 insertions(+) create mode 100644 test/Clownface/defaultGraph.js diff --git a/test/Clownface/defaultGraph.js b/test/Clownface/defaultGraph.js new file mode 100644 index 0000000..cd13c90 --- /dev/null +++ b/test/Clownface/defaultGraph.js @@ -0,0 +1,15 @@ +/* global describe, it */ + +const assert = require('assert') +const clownface = require('../..') +const rdf = require('../support/factory') + +describe('defaultGraph', () => { + it('returns defaultGraphInstance', () => { + const pointer = clownface({ dataset: rdf.dataset() }) + + const defaultGraph = pointer.defaultGraph + + assert(defaultGraph.equals(rdf.defaultGraphInstance)) + }) +}) diff --git a/test/Clownface/index.js b/test/Clownface/index.js index d8e7a32..7eae170 100644 --- a/test/Clownface/index.js +++ b/test/Clownface/index.js @@ -29,4 +29,5 @@ describe('Clownface', () => { require('./deleteOut') require('./deleteList') require('./fromGraph') + require('./defaultGraph') }) From b342b142da84553ac5240bed4c5c9bcefa7a0d6f Mon Sep 17 00:00:00 2001 From: tpluscode Date: Thu, 16 Jul 2020 16:19:15 +0200 Subject: [PATCH 3/7] refactor: handle fromGraph called on null graph pointer --- docs/api.md | 2 +- lib/Clownface.js | 9 ++++++++- test/Clownface/fromGraph.js | 27 +++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index d77542a..3233e57 100644 --- a/docs/api.md +++ b/docs/api.md @@ -484,7 +484,7 @@ Factory to create graph pointer objects [init.factory]DataFactory@rdfjs/data-model

an RDF/JS factory which will be used to create nodes

- [init._context]Context

an existing clownface context. takes precedence before other params

+ [init._context]Context | Array.<Context>

an existing clownface context. takes precedence before other params

diff --git a/lib/Clownface.js b/lib/Clownface.js index d6f3428..6cb8d2b 100644 --- a/lib/Clownface.js +++ b/lib/Clownface.js @@ -4,6 +4,8 @@ const toArray = require('./toArray') const toTermArray = require('./toTermArray') const Context = require('./Context') +const GRAPH = Symbol() + /** * A graph pointer object, which points at 0..N nodes within a dataset */ @@ -214,7 +216,7 @@ class Clownface { const context = values.reduce((context, value) => { return context.concat(this._context.reduce((all, current) => { - return all.concat([current.clone({ value })]) + return all.concat([current.clone({ value, graph: this[GRAPH] })]) }, [])) }, []) @@ -426,6 +428,11 @@ class Clownface { throw new Error('graph parameter is required') } + if (!this._context[0].term) { + this[GRAPH] = graph + return this + } + const context = this._context.map(context => context.clone({ graph: graph === null ? undefined : graph })) diff --git a/test/Clownface/fromGraph.js b/test/Clownface/fromGraph.js index b6b9fd8..6b1b9ce 100644 --- a/test/Clownface/fromGraph.js +++ b/test/Clownface/fromGraph.js @@ -7,6 +7,33 @@ const rdf = require('../support/factory') const ns = require('../support/namespace') describe('fromGraph', () => { + it('called on null pointer get applied to further calls', () => { + const term = ns.ex.Foo + const dataset = rdf.dataset([ + rdf.quad(term, rdfs.label, rdf.literal('default graph')), + rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) + ]) + const cf = clownface({ dataset }).fromGraph(ns.ex.NamedGraph) + + const pointer = cf.node(term) + + assert.deepStrictEqual(pointer.out(rdfs.label).value, 'named graph') + assert.deepStrictEqual(pointer._context[0].graph.value, ns.ex.NamedGraph.value) + }) + + it('called on null pointer does not affect later fromGraph calls', () => { + const term = ns.ex.Foo + const dataset = rdf.dataset([ + rdf.quad(term, rdfs.label, rdf.literal('graph one'), ns.ex.GraphOne), + rdf.quad(term, rdfs.label, rdf.literal('graph two'), ns.ex.GraphTwo) + ]) + const cf = clownface({ dataset }).fromGraph(ns.ex.GraphOne) + + const pointer = cf.node(term).fromGraph(ns.ex.GraphTwo) + + assert.deepStrictEqual(pointer._context[0].graph.value, ns.ex.GraphTwo.value) + }) + it('called with graph changes context to same term in named graph', () => { const term = ns.ex.Foo const dataset = rdf.dataset([ From facfe6f99c460e6ec3bacb189dac8bf6e24a4c2d Mon Sep 17 00:00:00 2001 From: tpluscode Date: Thu, 16 Jul 2020 16:21:12 +0200 Subject: [PATCH 4/7] docs: correct JSDoc of factory params --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 11cc7ad..9de9447 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,7 @@ const Clownface = require('./lib/Clownface') * @param {Term|Term[]} [init.term] one or more RDF/JS term(s) which will be the pointer's context * @param {string} [init.value] one or more raw values which will create literal node as the pointer's context * @param {DataFactory} [init.factory=@rdfjs/data-model] an RDF/JS factory which will be used to create nodes - * @param {Context} [init._context] an existing clownface context. takes precedence before other params + * @param {Context|Context[]} [init._context] an existing clownface context. takes precedence before other params * @returns {Clownface} */ function factory ({ dataset, graph, term, value, factory, _context }) { From 499da1381545cc96f36e3ee8be631f1a9b81689f Mon Sep 17 00:00:00 2001 From: tpluscode Date: Thu, 16 Jul 2020 16:23:37 +0200 Subject: [PATCH 5/7] docs: example of fromGraph method --- docs/named-graphs.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/docs/named-graphs.md b/docs/named-graphs.md index 3337e01..f539f26 100644 --- a/docs/named-graphs.md +++ b/docs/named-graphs.md @@ -2,7 +2,7 @@ ## Default behavior -The examples on all other pages do not specify any graph identifier. In this mode the traversal methods are free to navigate the entire dataset (aka. [union graph](https://patterns.dataincubator.org/book/union-graph.html)) but any triples added and removed only apply to the default graph. +The examples on all other pages do not specify any graph identifier. In this mode the traversal methods are free to navigate the entire dataset (aka. [union graph][union]) but any triples added and removed only apply to the default graph. @@ -63,3 +63,39 @@ nquads`${leonard.dataset}`.toString() ``` + +## Moving between graphs + +?> From v1.1 + +It is possible to move a graph pointer to the same node in different (named) graphs using a `fromGraph` method. It will return a new pointer with quads only originating from the desired graph. + +Use `null` value to move the pointer back to the [union graph][union]. + + + +```js +const cf = require('clownface') +const { dataset } = require('@rdfjs/dataset') +const namespace = require('@rdfjs/namespace') +const RDF = require('@rdfjs/data-model') +const { rdfs } = require('@tpluscode/rdf-ns-builders') + +const ex = namespace('https://example.com/') + +const quads = [ + RDF.quad(ex.Apple, rdfs.label, 'Apple', ex.EnglishLabels), + RDF.quad(ex.Apple, rdfs.label, 'Apfel', ex.GermanLabels), +] + +const apple = cf({ dataset: dataset(quads) }).node(tbbt.Apple) + +console.log({ + de: apple.fromGraph(ex.GermanLabels).out(rdfs.label).value, + en: apple.fromGraph(ex.EnglishLabels).out(rdfs.label).value, +}) +``` + + + +[union]: https://patterns.dataincubator.org/book/union-graph.html From 3b33b88040d469332115481081df41952e16f463 Mon Sep 17 00:00:00 2001 From: tpluscode Date: Thu, 16 Jul 2020 16:36:43 +0200 Subject: [PATCH 6/7] revert: simplify given that undefined is not a valid graph param --- lib/Clownface.js | 13 ++----------- lib/Context.js | 9 ++------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/Clownface.js b/lib/Clownface.js index 6cb8d2b..addbb90 100644 --- a/lib/Clownface.js +++ b/lib/Clownface.js @@ -4,8 +4,6 @@ const toArray = require('./toArray') const toTermArray = require('./toTermArray') const Context = require('./Context') -const GRAPH = Symbol() - /** * A graph pointer object, which points at 0..N nodes within a dataset */ @@ -216,7 +214,7 @@ class Clownface { const context = values.reduce((context, value) => { return context.concat(this._context.reduce((all, current) => { - return all.concat([current.clone({ value, graph: this[GRAPH] })]) + return all.concat([current.clone({ value })]) }, [])) }, []) @@ -428,14 +426,7 @@ class Clownface { throw new Error('graph parameter is required') } - if (!this._context[0].term) { - this[GRAPH] = graph - return this - } - - const context = this._context.map(context => context.clone({ - graph: graph === null ? undefined : graph - })) + const context = this._context.map(context => context.clone({ graph })) return Clownface.fromContext(context) } diff --git a/lib/Context.js b/lib/Context.js index 07ab298..5db9e70 100644 --- a/lib/Context.js +++ b/lib/Context.js @@ -12,13 +12,8 @@ class Context { this.term = term(value, undefined, undefined, factory) } - clone ({ dataset = this.dataset, graph, value, factory = this.factory, namespace = this.namespace }) { - let g = graph - if (typeof graph === 'undefined') { - g = undefined - } - - return new Context({ dataset, graph: g, value, factory, namespace }) + clone ({ dataset = this.dataset, graph = this.graph, value, factory = this.factory, namespace = this.namespace }) { + return new Context({ dataset, graph, value, factory, namespace }) } has (predicate, object) { From 042fc3fff1cecfb9b7dc691cafa584b6cf94f77a Mon Sep 17 00:00:00 2001 From: tpluscode Date: Mon, 17 Aug 2020 13:04:03 +0200 Subject: [PATCH 7/7] refactor: change the graph functionality --- docs/named-graphs.md | 37 ++++++++++++--- lib/Clownface.js | 13 +++-- test/Clownface/defaultGraph.js | 4 +- test/Clownface/fromGraph.js | 86 ---------------------------------- test/Clownface/inGraph.js | 48 +++++++++++++++++++ test/Clownface/index.js | 2 +- 6 files changed, 88 insertions(+), 102 deletions(-) delete mode 100644 test/Clownface/fromGraph.js create mode 100644 test/Clownface/inGraph.js diff --git a/docs/named-graphs.md b/docs/named-graphs.md index f539f26..36689a3 100644 --- a/docs/named-graphs.md +++ b/docs/named-graphs.md @@ -68,9 +68,7 @@ nquads`${leonard.dataset}`.toString() ?> From v1.1 -It is possible to move a graph pointer to the same node in different (named) graphs using a `fromGraph` method. It will return a new pointer with quads only originating from the desired graph. - -Use `null` value to move the pointer back to the [union graph][union]. +It is possible to move a graph pointer to the same node in different (named) graphs using a `inGraph` method. It will assume the current pointer to be the graph URI and return a new pointer where the `graph === term`. @@ -88,14 +86,41 @@ const quads = [ RDF.quad(ex.Apple, rdfs.label, 'Apfel', ex.GermanLabels), ] -const apple = cf({ dataset: dataset(quads) }).node(tbbt.Apple) +const pointer = cf({ dataset: dataset(quads) }) console.log({ - de: apple.fromGraph(ex.GermanLabels).out(rdfs.label).value, - en: apple.fromGraph(ex.EnglishLabels).out(rdfs.label).value, + de: pointer.node(ex.GermanLabels).inGraph().node(ex.Apple).out(rdfs.label).value, + en: pointer.node(ex.EnglishLabels).inGraph().node(ex.Apple).out(rdfs.label).value, }) ``` +The `inGraph` method takes an optional parameter which lets calling code map the pointer term to the graph URI. A common scenario could be to assume a hash base URI as frequently seen in RDF vocabularies. The example below takes the `rdf:Class` identifier and creates the named graph by removing the hash fragment from that URI. + + + +```js +const cf = require('clownface') +const { dataset } = require('@rdfjs/dataset') +const RDF = require('@rdfjs/data-model') +const { rdfs } = require('@tpluscode/rdf-ns-builders') + +const quads = [ + RDF.quad(rdfs.Class, rdfs.label, 'Class', rdfs()), +] + +function namedNodeWithoutHash (term) { + return rdf.namedNode(term.value.split('#')[0]) +} + +const pointer = cf({ dataset: dataset(quads) }) + .node(rdfs.Class) + .inGraph({ map: namedNodeWithoutHash }) + +console.log(pointer.out(rdfs.label).value) +``` + + + [union]: https://patterns.dataincubator.org/book/union-graph.html diff --git a/lib/Clownface.js b/lib/Clownface.js index addbb90..74add9e 100644 --- a/lib/Clownface.js +++ b/lib/Clownface.js @@ -421,18 +421,17 @@ class Clownface { return this } - fromGraph (graph) { - if (typeof graph === 'undefined') { - throw new Error('graph parameter is required') - } - - const context = this._context.map(context => context.clone({ graph })) + inGraph ({ map = term => term } = {}) { + const context = this._context.map(context => context.clone({ + value: context.term, + graph: map(context.term) + })) return Clownface.fromContext(context) } get defaultGraph () { - return rdf.defaultGraphInstance + return this.node(rdf.defaultGraphInstance) } _toTermArray (predicates, type, languageOrDatatype) { diff --git a/test/Clownface/defaultGraph.js b/test/Clownface/defaultGraph.js index cd13c90..25bb013 100644 --- a/test/Clownface/defaultGraph.js +++ b/test/Clownface/defaultGraph.js @@ -5,11 +5,11 @@ const clownface = require('../..') const rdf = require('../support/factory') describe('defaultGraph', () => { - it('returns defaultGraphInstance', () => { + it('returns pointer to default graph node', () => { const pointer = clownface({ dataset: rdf.dataset() }) const defaultGraph = pointer.defaultGraph - assert(defaultGraph.equals(rdf.defaultGraphInstance)) + assert(defaultGraph.term.equals(rdf.defaultGraphInstance)) }) }) diff --git a/test/Clownface/fromGraph.js b/test/Clownface/fromGraph.js deleted file mode 100644 index 6b1b9ce..0000000 --- a/test/Clownface/fromGraph.js +++ /dev/null @@ -1,86 +0,0 @@ -/* global describe, it */ - -const assert = require('assert') -const { rdfs } = require('@tpluscode/rdf-ns-builders') -const clownface = require('../..') -const rdf = require('../support/factory') -const ns = require('../support/namespace') - -describe('fromGraph', () => { - it('called on null pointer get applied to further calls', () => { - const term = ns.ex.Foo - const dataset = rdf.dataset([ - rdf.quad(term, rdfs.label, rdf.literal('default graph')), - rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) - ]) - const cf = clownface({ dataset }).fromGraph(ns.ex.NamedGraph) - - const pointer = cf.node(term) - - assert.deepStrictEqual(pointer.out(rdfs.label).value, 'named graph') - assert.deepStrictEqual(pointer._context[0].graph.value, ns.ex.NamedGraph.value) - }) - - it('called on null pointer does not affect later fromGraph calls', () => { - const term = ns.ex.Foo - const dataset = rdf.dataset([ - rdf.quad(term, rdfs.label, rdf.literal('graph one'), ns.ex.GraphOne), - rdf.quad(term, rdfs.label, rdf.literal('graph two'), ns.ex.GraphTwo) - ]) - const cf = clownface({ dataset }).fromGraph(ns.ex.GraphOne) - - const pointer = cf.node(term).fromGraph(ns.ex.GraphTwo) - - assert.deepStrictEqual(pointer._context[0].graph.value, ns.ex.GraphTwo.value) - }) - - it('called with graph changes context to same term in named graph', () => { - const term = ns.ex.Foo - const dataset = rdf.dataset([ - rdf.quad(term, rdfs.label, rdf.literal('default graph')), - rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) - ]) - const pointer = clownface({ dataset, term }) - - const movedPointer = pointer.fromGraph(ns.ex.NamedGraph) - - assert.deepStrictEqual(movedPointer.out(rdfs.label).value, 'named graph') - }) - - it('called with null changes context to same term across all graphs', () => { - const term = ns.ex.Foo - const dataset = rdf.dataset([ - rdf.quad(term, rdfs.label, rdf.literal('default graph')), - rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) - ]) - const pointer = clownface({ dataset, term, graph: ns.ex.NamedGraph }) - - const movedPointer = pointer.fromGraph(null) - - assert.deepStrictEqual(movedPointer.out(rdfs.label).values.length, 2) - }) - - it('called with undefined should throw', () => { - const term = ns.ex.Foo - const dataset = rdf.dataset([ - rdf.quad(term, rdfs.label, rdf.literal('default graph')), - rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) - ]) - const pointer = clownface({ dataset, term }) - - assert.throws(() => pointer.fromGraph(undefined)) - }) - - it('called with default graph instance changes context to same term in default graph', () => { - const term = ns.ex.Foo - const dataset = rdf.dataset([ - rdf.quad(term, rdfs.label, rdf.literal('default graph')), - rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) - ]) - const pointer = clownface({ dataset, term }) - - const movedPointer = pointer.fromGraph(rdf.defaultGraphInstance) - - assert.deepStrictEqual(movedPointer.out(rdfs.label).value, 'default graph') - }) -}) diff --git a/test/Clownface/inGraph.js b/test/Clownface/inGraph.js new file mode 100644 index 0000000..a39bc74 --- /dev/null +++ b/test/Clownface/inGraph.js @@ -0,0 +1,48 @@ +/* global describe, it */ + +const assert = require('assert') +const { rdfs } = require('@tpluscode/rdf-ns-builders') +const clownface = require('../..') +const rdf = require('../support/factory') +const ns = require('../support/namespace') + +describe('.inGraph', () => { + it('called on null pointer keeps null pointer', () => { + const term = ns.ex.Foo + const dataset = rdf.dataset([ + rdf.quad(term, rdfs.label, rdf.literal('default graph')), + rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.NamedGraph) + ]) + + const pointer = clownface({ dataset }).inGraph() + + assert.deepStrictEqual(typeof pointer.term, 'undefined') + }) + + it('called on pointer to graph switches to that graph', () => { + const term = ns.ex.Foo + const dataset = rdf.dataset([ + rdf.quad(term, rdfs.label, rdf.literal('default graph')), + rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.Foo) + ]) + const pointer = clownface({ dataset, term }) + + const movedPointer = pointer.inGraph() + + assert.deepStrictEqual(movedPointer.out(rdfs.label).value, 'named graph') + }) + + it('switches to graph returned by map parameter', () => { + const term = ns.ex.Foo + const dataset = rdf.dataset([ + rdf.quad(term, rdfs.label, rdf.literal('default graph')), + rdf.quad(term, rdfs.label, rdf.literal('named graph'), ns.ex.FooGraph) + ]) + const pointer = clownface({ dataset, term }) + const appendGraph = term => rdf.namedNode(term.value + 'Graph') + + const movedPointer = pointer.inGraph({ map: appendGraph }) + + assert.deepStrictEqual(movedPointer.out(rdfs.label).value, 'named graph') + }) +}) diff --git a/test/Clownface/index.js b/test/Clownface/index.js index 7eae170..9cc4124 100644 --- a/test/Clownface/index.js +++ b/test/Clownface/index.js @@ -28,6 +28,6 @@ describe('Clownface', () => { require('./deleteIn') require('./deleteOut') require('./deleteList') - require('./fromGraph') + require('./inGraph') require('./defaultGraph') })