@@ -27,7 +27,7 @@ describe("jsonld.put", function() {
2727 , predicate : "http://xmlns.com/foaf/0.1/name"
2828 , object : "Manu Sporny"
2929 } , function ( err , triples ) {
30- expect ( triples ) . to . have . property ( " length" , 1 ) ;
30+ expect ( triples ) . to . have . length ( 1 ) ;
3131 done ( ) ;
3232 } ) ;
3333 } ) ;
@@ -38,7 +38,7 @@ describe("jsonld.put", function() {
3838 db . get ( {
3939 subject : "http://manu.sporny.org#person"
4040 } , function ( err , triples ) {
41- expect ( triples ) . to . have . property ( " length" , 2 ) ;
41+ expect ( triples ) . to . have . length ( 2 ) ;
4242 done ( ) ;
4343 } ) ;
4444 } ) ;
@@ -49,7 +49,7 @@ describe("jsonld.put", function() {
4949 db . get ( {
5050 subject : "http://manu.sporny.org#person"
5151 } , function ( err , triples ) {
52- expect ( triples ) . to . have . property ( " length" , 2 ) ;
52+ expect ( triples ) . to . have . length ( 2 ) ;
5353 done ( ) ;
5454 } ) ;
5555 } ) ;
@@ -63,32 +63,36 @@ describe("jsonld.put", function() {
6363 , predicate : "http://xmlns.com/foaf/0.1/name"
6464 , object : "Manu Sporny"
6565 } , function ( err , triples ) {
66- expect ( triples ) . to . have . property ( " length" , 1 ) ;
66+ expect ( triples ) . to . have . length ( 1 ) ;
6767 done ( ) ;
6868 } ) ;
6969 } ) ;
7070 } ) ;
7171
7272 it ( "should generate an @id for unknown objects" , function ( done ) {
7373 delete manu [ "@id" ] ;
74+ var baseString = "http://levelgraph.org/tests/" ;
75+ var baseRegEx = / ^ h t t p : \/ \/ l e v e l g r a p h .o r g \/ t e s t s \/ / ;
7476
75- db . jsonld . put ( manu , { base : "http://levelgraph.org/tests/" } , function ( ) {
77+ db . jsonld . put ( manu , { base : baseString } , function ( ) {
7678 db . join ( {
7779 subject : db . v ( "subject" )
7880 , predicate : "http://xmlns.com/foaf/0.1/name"
7981 , object : "Manu Sporny"
8082 } , function ( err , contexts ) {
81- expect ( contexts [ 0 ] . subject . indexOf ( "http://levelgraph.org/tests/" ) ) . to . equal ( 0 ) ;
83+ expect ( contexts [ 0 ] . subject ) . to . match ( baseRegEx ) ;
8284 done ( ) ;
8385 } ) ;
8486 } ) ;
8587 } ) ;
8688
8789 it ( "should pass the generated @id to callback" , function ( done ) {
8890 delete manu [ "@id" ] ;
91+ var baseString = "http://levelgraph.org/tests/" ;
92+ var baseRegEx = / ^ h t t p : \/ \/ l e v e l g r a p h .o r g \/ t e s t s \/ / ;
8993
90- db . jsonld . put ( manu , { base : "http://levelgraph.org/tests/" } , function ( err , obj ) {
91- expect ( obj [ "@id" ] . indexOf ( "http://levelgraph.org/tests/" ) ) . to . equal ( 0 ) ;
94+ db . jsonld . put ( manu , { base : baseString } , function ( err , obj ) {
95+ expect ( obj [ "@id" ] ) . to . match ( baseRegEx ) ;
9296 done ( ) ;
9397 } ) ;
9498 } ) ;
@@ -100,7 +104,7 @@ describe("jsonld.put", function() {
100104 , predicate : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
101105 , object : "http://purl.org/goodrelations/v1#Offering"
102106 } , function ( err , triples ) {
103- expect ( triples ) . to . have . property ( " length" , 1 ) ;
107+ expect ( triples ) . to . have . length ( 1 ) ;
104108 done ( ) ;
105109 } ) ;
106110 } ) ;
@@ -115,7 +119,7 @@ describe("jsonld.put", function() {
115119 , predicate : "http://xmlns.com/foaf/0.1/homepage"
116120 , object : "http://another/website"
117121 } , function ( err , triples ) {
118- expect ( triples ) . to . have . property ( " length" , 1 ) ;
122+ expect ( triples ) . to . have . length ( 1 ) ;
119123 done ( ) ;
120124 } ) ;
121125 } ) ;
@@ -133,7 +137,7 @@ describe("jsonld.put", function() {
133137 , predicate : "http://xmlns.com/foaf/0.1/age"
134138 , object : 42
135139 } , function ( err , triples ) {
136- expect ( triples ) . to . have . property ( " length" , 1 ) ;
140+ expect ( triples ) . to . have . length ( 1 ) ;
137141 done ( ) ;
138142 } ) ;
139143 } ) ;
@@ -149,7 +153,7 @@ describe("jsonld.put", function() {
149153 subject : "http://manu.sporny.org#person"
150154 , predicate : "http://xmlns.com/foaf/0.1/homepage"
151155 } , function ( err , triples ) {
152- expect ( triples ) . to . have . property ( "length" , 0 ) ;
156+ expect ( triples ) . to . be . empty ;
153157 done ( ) ;
154158 } ) ;
155159 } ) ;
@@ -165,7 +169,7 @@ describe("jsonld.put", function() {
165169 subject : "http://example.org/cars/for-sale#tesla"
166170 , predicate : "http://purl.org/goodrelations/v1#"
167171 } , function ( err , triples ) {
168- expect ( triples ) . to . have . property ( "length" , 0 ) ;
172+ expect ( triples ) . to . be . empty ;
169173 done ( ) ;
170174 } ) ;
171175 } ) ;
@@ -194,7 +198,7 @@ describe("jsonld.put with default base", function() {
194198 , predicate : "http://xmlns.com/foaf/0.1/name"
195199 , object : "Manu Sporny"
196200 } , function ( err , triples ) {
197- expect ( triples ) . to . have . property ( " length" , 1 ) ;
201+ expect ( triples ) . to . have . length ( 1 ) ;
198202 done ( ) ;
199203 } ) ;
200204 } ) ;
@@ -237,7 +241,7 @@ describe("jsonld.put with default base", function() {
237241
238242 db . jsonld . put ( nested , function ( ) {
239243 db . get ( { } , function ( err , triples ) {
240- expect ( triples ) . to . have . property ( " length" , 5 ) ;
244+ expect ( triples ) . to . have . length ( 5 ) ;
241245 done ( ) ;
242246 } ) ;
243247 } ) ;
0 commit comments