@@ -14,8 +14,9 @@ describe('formats', function () {
1414
1515 var server = supertest ( address ) ;
1616 describe ( 'HTML' , function ( ) {
17- it ( 'Should return "Hello, World!"' , function ( done ) {
17+ it ( 'Should return HTML containing "Hello, World!" if Accept is set to text/html ' , function ( done ) {
1818 server . get ( '/hello.html' )
19+ . set ( 'accept' , 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5' )
1920 . expect ( 'Content-type' , / t e x t \/ h t m l / )
2021 . expect ( / H e l l o , w o r l d ! / )
2122 . expect ( 200 , done ) ;
@@ -26,35 +27,43 @@ describe('formats', function () {
2627 var isValidJSON = function ( res ) {
2728 var json = JSON . parse ( res . text ) ;
2829 } ;
29- it ( 'Should return JSON-LD document' , function ( done ) {
30+ it ( 'Should return JSON-LD document if Accept is set to application/ld+json ' , function ( done ) {
3031 server . get ( '/patch-5-initial.ttl' )
31- . set ( 'accept' , 'application/json+ld ' )
32- . expect ( 'content-type' , / a p p l i c a t i o n \/ j s o n \+ l d / )
32+ . set ( 'accept' , 'application/ld+json;q=0.9,text/turtle;q=0.8,text/plain;q=0.7,*/*;q=0.5 ' )
33+ . expect ( 'content-type' , / a p p l i c a t i o n \/ l d \+ j s o n / )
3334 . expect ( 200 , done ) ;
3435 } ) ;
35- it ( 'Should return valid JSON' , function ( done ) {
36+ it ( 'Should return valid JSON if Accept is set to JSON-LD ' , function ( done ) {
3637 server . get ( '/patch-5-initial.ttl' )
37- . set ( 'accept' , 'application/json+ld ' )
38+ . set ( 'accept' , 'application/ld+json;q=0.9,text/turtle;q=0.8,text/plain;q=0.7,*/*;q=0.5 ' )
3839 . expect ( isValidJSON )
3940 . expect ( 200 , done ) ;
4041 } ) ;
4142 } ) ;
4243
4344 describe ( 'N-Quads' , function ( ) {
44- it ( 'Should return N-Quads document' , function ( done ) {
45+ it ( 'Should return N-Quads document is Accept is set to application/n-quads ' , function ( done ) {
4546 server . get ( '/patch-5-initial.ttl' )
46- . set ( 'accept' , 'application/n-quads' )
47+ . set ( 'accept' , 'application/n-quads;q=0.9,text/turtle;q=0.8,text/plain;q=0.7,*/*;q=0.5 ' )
4748 . expect ( 'content-type' , / a p p l i c a t i o n \/ n - q u a d s / )
4849 . expect ( 200 , done ) ;
4950 } ) ;
5051 } ) ;
5152
5253 describe ( 'n3' , function ( ) {
53- it ( 'Should return turtle document if content-type set to n3' , function ( done ) {
54+ it ( 'Should return turtle document if Accept is set to text/ n3' , function ( done ) {
5455 server . get ( '/patch-5-initial.ttl' )
55- . set ( 'accept' , 'text/n3' )
56+ . set ( 'accept' , 'text/n3;q=0.9,text/turtle;q=0.8,text/plain;q=0.7,*/*;q=0.5 ' )
5657 . expect ( 'content-type' , / t e x t \/ n 3 / )
5758 . expect ( 200 , done ) ;
5859 } ) ;
5960 } ) ;
61+
62+ describe ( 'none' , function ( ) {
63+ it ( 'Should return turtle document if no Accept header is set' , function ( done ) {
64+ server . get ( '/patch-5-initial.ttl' )
65+ . expect ( 'content-type' , / t e x t \/ t u r t l e / )
66+ . expect ( 200 , done ) ;
67+ } ) ;
68+ } ) ;
6069} ) ;
0 commit comments