Skip to content

Commit

Permalink
JSON-LD to other formats fails against NSS
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Aug 31, 2020
1 parent 1c9a59f commit 9d4928b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
6 changes: 6 additions & 0 deletions test/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@id": "http://store.example.com/",
"@type": "Store",
"name": "Links Bike Shop",
"description": "The most \"linked\" bike store on earth!"
}
44 changes: 41 additions & 3 deletions test/surface/conneg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { testFolderUrl } from '../helpers/global';
import { getAuthFetcher } from '../helpers/obtain-auth-headers';

const example = {
html: readFileSync('test/fixtures/example.html'),
turtle: readFileSync('test/fixtures/example.ttl'),
json: readFileSync('test/fixtures/example.json'),
html: readFileSync('test/fixtures/example.html').toString(),
turtle: readFileSync('test/fixtures/example.ttl').toString(),
json: readFileSync('test/fixtures/example.json').toString(),
};

const triplesFromHtml = [
Expand Down Expand Up @@ -239,4 +239,42 @@ describe('Alice\'s pod', () => {
});
});
});
describe('GET JSON-LD', () => {
describe("As JSON-LD", () => {
let jsonText;
beforeAll(async () => {
jsonText = await getAs(`${testFolderUrl}example.json`, 'application/ld+json');
});
test("JSON content", async () => {
console.log(jsonText);
const obj = JSON.parse(jsonText);
expect(obj).toEqual([
{
"@id": "http://store.example.com/",
"@type": "Store",
"name": "Links Bike Shop",
"description": "The most \"linked\" bike store on earth!"
},
]);
});
test("Triples", async () => {
const triples = await asTriples(jsonText, `${testFolderUrl}example.json`, 'application/ld+json');
expect(triples).toEqual([]);
});
});
describe("As Turtle", () => {
let text;
beforeAll(async () =>{
text = await getAs(`${testFolderUrl}example.json`, 'text/turtle');
});
test("Turtle content", async () => {
console.log(text);
expect(text).toEqual('<http://store.example.com/> a <Store> .\n');
});
test("Triples", async () => {
const triples = await asTriples(text, `${testFolderUrl}example.ttl`, 'text/turtle');
expect(triples).toEqual([]);
});
});
});
});

0 comments on commit 9d4928b

Please sign in to comment.