-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5257789
commit 3f77cc9
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix ex: <https://example.org/> . | ||
|
||
ex:person1 a ex:Person . | ||
[] a ex:Person . | ||
|
||
ex:personShape a sh:NodeShape ; | ||
sh:targetClass ex:Person ; | ||
sh:node [ sh:nodeKind sh:BlankNode ] . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint-env mocha */ | ||
import path from 'path' | ||
import assert from 'assert' | ||
import * as url from 'url' | ||
import RDF from '@zazuko/env-node' | ||
import SHACLValidator from '../index.js' | ||
import { loadDataset } from './utils.js' | ||
|
||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) | ||
const rootPath = path.join(__dirname, '/data/validation-details') | ||
|
||
describe('validation details', () => { | ||
it('creates detail for node constraint', async () => { | ||
const data = await loadDataset(path.join(rootPath, 'node-constraint-details.ttl')) | ||
const shapes = data | ||
|
||
const validator = new SHACLValidator(shapes) | ||
const report = validator.validate(data) | ||
|
||
assert.equal(1, report.results.length) | ||
const result = report.results[0] | ||
assert.deepStrictEqual(result.sourceConstraintComponent, RDF.ns.sh.NodeConstraintComponent) | ||
assert.deepStrictEqual(result.focusNode, RDF.namedNode('https://example.org/person1')) | ||
assert.deepStrictEqual(result.value, RDF.namedNode('https://example.org/person1')) | ||
|
||
assert.equal(1, result.detail.length) | ||
const detail = result.detail[0] | ||
assert.deepStrictEqual(detail.sourceConstraintComponent, RDF.ns.sh.NodeKindConstraintComponent) | ||
assert.deepStrictEqual(detail.focusNode, RDF.namedNode('https://example.org/person1')) | ||
assert.deepStrictEqual(detail.value, RDF.namedNode('https://example.org/person1')) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters