11var supertest = require ( 'supertest' )
22var ldnode = require ( '../index' )
33var path = require ( 'path' )
4+ const assert = require ( 'chai' ) . assert
45
56describe ( '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' , / a p p l i c a t i o n \/ l d \+ j s o n / )
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' , / a p p l i c a t i o n \/ l d \+ j s o n / )
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