@@ -33,92 +33,122 @@ describe('PATCH', function () {
3333 ldp . listen ( 3453 ) ;
3434 var server = supertest ( 'http://localhost:3453/test' ) ;
3535
36- describe ( 'POST' , function ( ) {
37-
38- it ( 'should be an empty resource if last triple is deleted' , function ( done ) {
39- write (
40- '<#current> <#temp> 123 .' ,
41- 'testfiles/existingTriple.ttl' ) ;
42- server . post ( '/existingTriple.ttl' )
43- . set ( 'content-type' , 'application/sparql-update' )
44- . send ( 'DELETE { :current :temp 123 .}' )
45- . expect ( 200 )
46- . end ( function ( err , res , body ) {
47- assert . equal (
48- read ( 'testfiles/existingTriple.ttl' ) ,
49- '\n' ) ;
50- rm ( 'testfiles/existingTriple.ttl' ) ;
51- done ( err ) ;
52- } ) ;
53- } ) ;
36+ it ( 'should be an empty resource if last triple is deleted' , function ( done ) {
37+ write (
38+ '<#current> <#temp> 123 .' ,
39+ 'testfiles/existingTriple.ttl' ) ;
40+ server . post ( '/existingTriple.ttl' )
41+ . set ( 'content-type' , 'application/sparql-update' )
42+ . send ( 'DELETE { :current :temp 123 .}' )
43+ . expect ( 200 )
44+ . end ( function ( err , res , body ) {
45+ assert . equal (
46+ read ( 'testfiles/existingTriple.ttl' ) ,
47+ '\n' ) ;
48+ rm ( 'testfiles/existingTriple.ttl' ) ;
49+ done ( err ) ;
50+ } ) ;
51+ } ) ;
5452
55- it ( 'should add a new triple' , function ( done ) {
56- write (
57- '<#current> <#temp> 123 .' ,
58- 'testfiles/addingTriple.ttl' ) ;
59- server . post ( '/addingTriple.ttl' )
60- . set ( 'content-type' , 'application/sparql-update' )
61- . send ( 'INSERT DATA { :test :hello 456 .}' )
62- . expect ( 200 )
63- . end ( function ( err , res , body ) {
64- assert . equal (
65- read ( 'testfiles/addingTriple.ttl' ) ,
66- '\n <#current> <#temp> 123 .\n <#test> <#hello> 456 .\n' ) ;
67- rm ( 'testfiles/addingTriple.ttl' ) ;
68- done ( err ) ;
69- } ) ;
70- } ) ;
53+ it ( 'should be update a resource using SPARQL-query using `prefix`' , function ( done ) {
54+ write (
55+ '@prefix schema: <http://schema.org/> .\n' +
56+ '@prefix profile: <http://ogp.me/ns/profile#> .\n' +
57+ '# <http://example.com/timbl#> a schema:Person ;\n' +
58+ '<#> a schema:Person ;\n' +
59+ ' profile:first_name "Tim" .\n' ,
60+ 'testfiles/prefixSparql.ttl' ) ;
61+ server . post ( '/prefixSparql.ttl' )
62+ . set ( 'content-type' , 'application/sparql-update' )
63+ . send ( '@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n' +
64+ '@prefix schema: <http://schema.org/> .\n' +
65+ '@prefix profile: <http://ogp.me/ns/profile#> .\n' +
66+ '@prefix ex: <http://example.org/vocab#> .\n' +
67+ 'DELETE { <#> profile:first_name "Tim" }\n' +
68+ 'INSERT { <#> profile:first_name "Timothy" }' )
69+ . expect ( 200 )
70+ . end ( function ( err , res , body ) {
71+ assert . equal (
72+ read ( 'testfiles/prefixSparql.ttl' ) ,
73+ '@prefix schema: <http://schema.org/>.\n' +
74+ '@prefix profile: <http://ogp.me/ns/profile#>.\n' +
75+ '\n' +
76+ ' <#> profile:first_name "Timothy"; a schema:Person .\n' ) ;
77+ rm ( 'testfiles/prefixSparql.ttl' ) ;
78+ done ( err ) ;
79+ } ) ;
80+ } ) ;
7181
72- it ( 'should add value to existing triple' , function ( done ) {
73- write (
74- '<#current> <#temp> 123 .' ,
75- 'testfiles/addingTripleValue.ttl' ) ;
76- server . post ( '/addingTripleValue.ttl' )
77- . set ( 'content-type' , 'application/sparql-update' )
78- . send ( 'INSERT DATA { :current :temp 456 .}' )
79- . expect ( 200 )
80- . end ( function ( err , res , body ) {
81- assert . equal (
82- read ( 'testfiles/addingTripleValue.ttl' ) ,
83- '\n <#current> <#temp> 123, 456 .\n' ) ;
84- rm ( 'testfiles/addingTripleValue.ttl' ) ;
85- done ( err ) ;
86- } ) ;
87- } ) ;
82+ it ( 'should add a new triple' , function ( done ) {
83+ write (
84+ '<#current> <#temp> 123 .' ,
85+ 'testfiles/addingTriple.ttl' ) ;
86+ server . post ( '/addingTriple.ttl' )
87+ . set ( 'content-type' , 'application/sparql-update' )
88+ . send ( 'INSERT DATA { :test :hello 456 .}' )
89+ . expect ( 200 )
90+ . end ( function ( err , res , body ) {
91+ assert . equal (
92+ read ( 'testfiles/addingTriple.ttl' ) ,
93+ '\n' +
94+ ' <#current> <#temp> 123 .\n' +
95+ ' <#test> <#hello> 456 .\n' ) ;
96+ rm ( 'testfiles/addingTriple.ttl' ) ;
97+ done ( err ) ;
98+ } ) ;
99+ } ) ;
88100
89- it ( 'should add value to same subject' , function ( done ) {
90- write (
91- '<#current> <#temp> 123 .' ,
92- 'testfiles/addingTripleSubj.ttl' ) ;
93- server . post ( '/addingTripleSubj.ttl' )
94- . set ( 'content-type' , 'application/sparql-update' )
95- . send ( 'INSERT DATA { :current :temp2 456 .}' )
96- . expect ( 200 )
97- . end ( function ( err , res , body ) {
98- assert . equal (
99- read ( 'testfiles/addingTripleSubj.ttl' ) ,
100- '\n <#current> <#temp2> 456; <#temp> 123 .\n' ) ;
101- rm ( 'testfiles/addingTripleSubj.ttl' ) ;
102- done ( err ) ;
103- } ) ;
104- } ) ;
101+ it ( 'should add value to existing triple' , function ( done ) {
102+ write (
103+ '<#current> <#temp> 123 .' ,
104+ 'testfiles/addingTripleValue.ttl' ) ;
105+ server . post ( '/addingTripleValue.ttl' )
106+ . set ( 'content-type' , 'application/sparql-update' )
107+ . send ( 'INSERT DATA { :current :temp 456 .}' )
108+ . expect ( 200 )
109+ . end ( function ( err , res , body ) {
110+ assert . equal (
111+ read ( 'testfiles/addingTripleValue.ttl' ) ,
112+ '\n' +
113+ ' <#current> <#temp> 123, 456 .\n' ) ;
114+ rm ( 'testfiles/addingTripleValue.ttl' ) ;
115+ done ( err ) ;
116+ } ) ;
117+ } ) ;
105118
106- it ( 'nothing should change with empty patch' , function ( done ) {
107- write (
108- '<#current> <#temp> 123 .' ,
109- 'testfiles/emptyExample.ttl' ) ;
110- server . post ( '/emptyExample.ttl' )
111- . set ( 'content-type' , 'application/sparql-update' )
112- . send ( '' )
113- . expect ( 200 )
114- . end ( function ( err , res , body ) {
115- assert . equal (
116- read ( 'testfiles/emptyExample.ttl' ) ,
117- '\n <#current> <#temp> 123 .\n' ) ;
118- rm ( 'testfiles/emptyExample.ttl' ) ;
119- done ( err ) ;
120- } ) ;
121- } ) ;
119+ it ( 'should add value to same subject' , function ( done ) {
120+ write (
121+ '<#current> <#temp> 123 .' ,
122+ 'testfiles/addingTripleSubj.ttl' ) ;
123+ server . post ( '/addingTripleSubj.ttl' )
124+ . set ( 'content-type' , 'application/sparql-update' )
125+ . send ( 'INSERT DATA { :current :temp2 456 .}' )
126+ . expect ( 200 )
127+ . end ( function ( err , res , body ) {
128+ assert . equal (
129+ read ( 'testfiles/addingTripleSubj.ttl' ) ,
130+ '\n' +
131+ ' <#current> <#temp2> 456; <#temp> 123 .\n' ) ;
132+ rm ( 'testfiles/addingTripleSubj.ttl' ) ;
133+ done ( err ) ;
134+ } ) ;
135+ } ) ;
122136
137+ it ( 'nothing should change with empty patch' , function ( done ) {
138+ write (
139+ '<#current> <#temp> 123 .' ,
140+ 'testfiles/emptyExample.ttl' ) ;
141+ server . post ( '/emptyExample.ttl' )
142+ . set ( 'content-type' , 'application/sparql-update' )
143+ . send ( '' )
144+ . expect ( 200 )
145+ . end ( function ( err , res , body ) {
146+ assert . equal (
147+ read ( 'testfiles/emptyExample.ttl' ) ,
148+ '\n' +
149+ ' <#current> <#temp> 123 .\n' ) ;
150+ rm ( 'testfiles/emptyExample.ttl' ) ;
151+ done ( err ) ;
152+ } ) ;
123153 } ) ;
124154} ) ;
0 commit comments