|
| 1 | +/* |
| 2 | + * Test generation of RDF without a base IRI. |
| 3 | + */ |
| 4 | + |
| 5 | +const fs = require('fs'); |
| 6 | +const path = require('path'); |
| 7 | + |
| 8 | +const chai = require('chai'); |
| 9 | +const phyx = require('../src'); |
| 10 | + |
| 11 | +const expect = chai.expect; |
| 12 | + |
| 13 | +/** |
| 14 | + * Test whether conversion of Phyx files to an OWL ontology in RDF works even without a baseIRI. |
| 15 | + * This was an issue in https://github.com/phyloref/phyx.js/issues/113 |
| 16 | + */ |
| 17 | + |
| 18 | +describe('PhyxWrapper', function () { |
| 19 | + describe('toRDF() without baseIRI', function () { |
| 20 | + const examples = fs.readdirSync(path.resolve(__dirname, './examples/correct')) |
| 21 | + .filter(filename => filename.endsWith('.json')); |
| 22 | + |
| 23 | + examples.forEach((example) => { |
| 24 | + const basename = path.resolve(__dirname, './examples/correct', path.parse(example).name); |
| 25 | + const jsonFilename = `${basename}.json`; |
| 26 | + |
| 27 | + let json; |
| 28 | + |
| 29 | + describe(`Test file '${example}'`, function () { |
| 30 | + it('should be loadable', function () { |
| 31 | + json = JSON.parse(fs.readFileSync(jsonFilename)); |
| 32 | + expect(json).to.be.an('object'); |
| 33 | + }); |
| 34 | + |
| 35 | + it('should be convertible to n-Quads without a baseIRI', function () { |
| 36 | + this.timeout(10000); |
| 37 | + return new phyx.PhyxWrapper(json).toRDF('', path.resolve(__dirname, 'examples', 'correct')) |
| 38 | + .then((nquads) => { |
| 39 | + expect(nquads).to.not.be.empty; |
| 40 | + expect(nquads).to.contain('http://ontology.phyloref.org/phyloref.owl#Phyloreference'); |
| 41 | + expect(nquads).to.contain('http://ontology.phyloref.org/phyloref.owl#newick_expression'); |
| 42 | + }); |
| 43 | + }); |
| 44 | + }); |
| 45 | + }); |
| 46 | + }); |
| 47 | +}); |
0 commit comments