Skip to content

Commit 507866e

Browse files
Add failing test for issue #476
1 parent 47c47e3 commit 507866e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

test/formats.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var supertest = require('supertest')
22
var ldnode = require('../index')
33
var path = require('path')
4+
const assert = require('chai').assert
45

56
describe('formats', function () {
67
var ldp = ldnode.createServer({
@@ -19,7 +20,14 @@ describe('formats', function () {
1920
})
2021

2122
describe('JSON-LD', function () {
22-
var isValidJSON = function (res) {
23+
function isCorrectSubject (idFragment) {
24+
return (res) => {
25+
var payload = JSON.parse(res.text)
26+
var id = payload[0]['@id']
27+
assert(id.endsWith(idFragment), 'The subject of the JSON-LD graph is correct')
28+
}
29+
}
30+
function isValidJSON (res) {
2331
// This would throw an error
2432
JSON.parse(res.text)
2533
}
@@ -28,6 +36,8 @@ describe('formats', function () {
2836
.set('accept', 'application/ld+json')
2937
.expect(200)
3038
.expect('content-type', /application\/ld\+json/)
39+
.expect(isValidJSON)
40+
.expect(isCorrectSubject('/patch-5-initial.ttl#Iss1408851516666'))
3141
.end(done)
3242
})
3343
it('should return the container listing in JSON-LD if Accept is set to only application/ld+json', function (done) {
@@ -49,12 +59,6 @@ describe('formats', function () {
4959
.expect('content-type', /application\/ld\+json/)
5060
.expect(200, done)
5161
})
52-
it('should return valid JSON if Accept is set to JSON-LD', function (done) {
53-
server.get('/patch-5-initial.ttl')
54-
.set('accept', 'application/ld+json')
55-
.expect(isValidJSON)
56-
.expect(200, done)
57-
})
5862
})
5963

6064
describe('N-Quads', function () {

0 commit comments

Comments
 (0)