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