@@ -34,14 +34,83 @@ describe('PATCH', function () {
3434 var server = supertest ( 'http://localhost:3453/test' ) ;
3535
3636 describe ( 'POST' , function ( ) {
37- write (
38- '<#current> <#temp> 123 .' ,
39- 'testfiles/emptyExample.ttl' ) ;
4037
41- it ( 'nothing should change with an empty file' , function ( done ) {
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+ } ) ;
54+
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+ } ) ;
71+
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+ } ) ;
88+
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+ } ) ;
105+
106+ it ( 'nothing should change with empty patch' , function ( done ) {
107+ write (
108+ '<#current> <#temp> 123 .' ,
109+ 'testfiles/emptyExample.ttl' ) ;
42110 server . post ( '/emptyExample.ttl' )
43111 . set ( 'content-type' , 'application/sparql-update' )
44112 . send ( '' )
113+ . expect ( 200 )
45114 . end ( function ( err , res , body ) {
46115 assert . equal (
47116 read ( 'testfiles/emptyExample.ttl' ) ,
0 commit comments