@@ -80,28 +80,21 @@ describe('woql queries', function () {
80
80
const Update = WOQL . addClass ( "id" ) ;
81
81
const Condition = WOQL . or ( WOQL . triple ( "a" , "b" , "c" ) , WOQL . triple ( "1" , "2" , "3" ) ) ;
82
82
83
- const woqlObject = WOQL . when ( Condition , Update ) ;
83
+ const woqlObject = WOQL . when ( true , WOQL . addClass ( "id" ) ) ;
84
+
85
+ const woqlObjectChain = WOQL . when ( true ) . addClass ( "id" )
84
86
85
- const woqlObjectChain = WOQL . when ( Condition ) . addClass ( "id" )
86
- //console.log(woqlObject.json()['when'][0][]);
87
- console . log ( woqlObjectChain . json ( ) ) ;
88
- /*
89
87
const jsonObj = {
90
88
when : [
91
- WOQLQuery {
92
- query: [Object],
93
- cursor: [Object],
94
- chain_ended: false,
95
- contains_update: false,
96
- paging_transitive_properties: [Array],
97
- vocab: [Object]
89
+ {
90
+ "true" :[ ]
98
91
} ,
99
- {}
92
+ { add_quad : [ 'scm:id' , 'rdf:type' , 'owl:Class' , 'db:schema' ] }
100
93
]
101
94
} ;
102
- */
95
+
103
96
//expect(woqlObject.json()).to.eql(jsonObj);
104
- // expect(woqlObjectChain.json()).to.eql(jsonObj);
97
+ expect ( woqlObjectChain . json ( ) ) . to . eql ( jsonObj ) ;
105
98
106
99
} )
107
100
@@ -231,9 +224,9 @@ describe('woql queries', function () {
231
224
232
225
it ( 'check the get method' , function ( ) {
233
226
234
- const woqlObject = WOQL . as ( "Map" , "Target" ) ;
227
+ const woqlObject = WOQL . get ( "Map" , "Target" ) ;
235
228
236
- const jsonObj = { as : [ { '@value' : 'Map' } , 'v:Target' ] } ;
229
+ const jsonObj = { get : [ [ ] , { } ] } ;
237
230
238
231
expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
239
232
@@ -242,28 +235,32 @@ describe('woql queries', function () {
242
235
it ( 'check the as method' , function ( ) {
243
236
244
237
const woqlObject = WOQL . as ( "Source" , "Target" ) ;
238
+ const woqlObject2 = WOQL . as ( "Source" , "Target" ) . as ( "Source2" , "Target2" ) ;
245
239
246
- const jsonObj = { as : [ { '@value' : 'Source' } , 'v:Target' ] } ;
240
+ const jsonObj = [ { as : [ { '@value' : 'Source' } , 'v:Target' ] } ] ;
241
+ const jsonObj2 = [ { as : [ { '@value' : 'Source' } , 'v:Target' ] } ,
242
+ { as : [ { '@value' : 'Source2' } , 'v:Target2' ] } ]
247
243
248
244
expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
245
+ expect ( woqlObject2 . json ( ) ) . to . eql ( jsonObj2 ) ;
249
246
250
247
} )
251
248
252
249
it ( 'check the remote method' , function ( ) {
253
250
254
251
const woqlObject = WOQL . remote ( { url : "http://url" } ) ;
255
- console . log ( woqlObject . json ( ) ) ;
256
- //const jsonObj={ as: [ { '@value ': 'Prefix' }, 'v:V1,V2' ] };
257
252
258
- //expect(woqlObject.json()).to.eql(jsonObj);
253
+ const jsonObj = { remote : [ { url : 'http://url' } ] } ;
254
+
255
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
259
256
260
257
} )
261
258
262
259
it ( 'check the unique method' , function ( ) {
263
260
264
- const woqlObject = WOQL . as ( "Prefix" , [ "V1" , "V2" ] ) ;
261
+ const woqlObject = WOQL . unique ( "doc:Station_" , [ "v:Start_ID" ] , "v:Start_IRI" ) ;
265
262
266
- const jsonObj = { as : [ { '@value' : 'Prefix' } , 'v:V1,V2 ' ] } ;
263
+ const jsonObj = { unique : [ 'doc:Station_' , { list : [ "v:Start_ID" ] } , 'v:Start_IRI ' ] }
267
264
268
265
expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
269
266
@@ -272,10 +269,10 @@ describe('woql queries', function () {
272
269
it ( 'check the list method' , function ( ) {
273
270
274
271
const woqlObject = WOQL . list ( [ "V1" , "V2" ] ) ;
275
- console . log ( woqlObject . json ( ) ) ;
276
- //const jsonObj={ as: [ { '@value ': 'Prefix' }, 'v:V1,V2' ] };
277
272
278
- //expect(woqlObject.json()).to.eql(jsonObj);
273
+ const jsonObj = { list : [ [ 'V1' , 'V2' ] ] } ;
274
+
275
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
279
276
280
277
} )
281
278
@@ -317,7 +314,10 @@ describe('triple builder', function () {
317
314
318
315
const woqlObject = WOQL . deleteClass ( "id" ) ;
319
316
320
- const jsonObj = { and : [ { delete_quad : [ 'scm:id' , 'v:All' , 'v:Al2' , 'db:schema' ] } , { opt : [ { delete_quad : [ 'v:Al3' , 'v:Al4' , 'scm:id' , 'db:schema' ] } ] } ] } ;
317
+ const jsonObj = { and : [
318
+ { delete_quad : [ 'scm:id' , 'v:All' , 'v:Al2' , 'db:schema' ] } ,
319
+ { "opt" : [ { delete_quad : [ 'v:Al3' , 'v:Al4' , 'scm:id' , 'db:schema' ] } ] }
320
+ ] } ;
321
321
322
322
expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
323
323
@@ -446,17 +446,33 @@ describe('triple builder chanier', function () {
446
446
447
447
const woqlObject = WOQL . node ( "doc:x" , "add_quad" ) . label ( "my label" , "en" ) ;
448
448
449
- const jsonObj = { add_quad : [ "doc:x" , 'rdfs:label' , { '@value' : 'my label' , '@language' : 'en' } , 'db:schema' ] } ;
449
+ const jsonObj = { add_quad : [ 'doc:x' , 'rdfs:label' , { '@value' : 'my label' , '@language' : 'en' } , 'db:schema' ] } ;
450
+
451
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
452
+
453
+ } )
454
+
455
+ it ( 'check the description method' , function ( ) {
456
+
457
+ const woqlObject = WOQL . addClass ( "New class" ) . description ( "A new class object." ) . entity ( ) ;
458
+
459
+ const jsonObj = { "add_quad" : [ 'doc:x' , 'rdfs:comment' , { '@value' : 'my comment' , '@language' : 'en' } , 'db:schema' ] } ;
450
460
451
461
expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
452
462
453
463
} )
454
464
455
465
it ( 'check the comment method' , function ( ) {
456
466
457
- const woqlObject = WOQL . comment ( "Comments Out the Following" ) . add_triple ( " doc:x", "type" , "scm:Yoke ") ;
467
+ const woqlObject = WOQL . node ( " doc:x", "add_quad" ) . comment ( "my comment ") ;
458
468
459
- const jsonObj = { comment : [ { "@value" : 'Comments Out the Following' , "@language" : 'en' } , { "add_triple" : [ "doc:x" , "rdf:type" , "scm:Yoke" ] } ] } ;
469
+ const jsonObj = { "comment" : [
470
+ {
471
+ "@language" : "en" ,
472
+ "@value" : "my comment"
473
+ } ,
474
+ { }
475
+ ] } ;
460
476
461
477
expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
462
478
@@ -476,23 +492,19 @@ describe('triple builder chanier', function () {
476
492
477
493
const woqlObject = WOQL . node ( "doc:x" , "add_quad" ) . entity ( ) ;
478
494
479
- console . log ( woqlObject . json ( ) ) ;
480
-
481
- //const jsonObj={ add_quad: ['doc:x', 'rdfs:myprop', { '@value ': 'my value', '@language': 'en' }, 'db:schema'] }
495
+ const jsonObj = { add_quad : [ 'doc:x' , 'rdfs:subClassOf' , 'tcs:Entity' , 'db:schema' ] } ;
482
496
483
- // expect(woqlObject.json()).to.eql(jsonObj);
497
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
484
498
485
499
} )
486
500
487
501
it ( 'check the parent method' , function ( ) {
488
502
489
503
const woqlObject = WOQL . node ( "doc:x" , "add_quad" ) . parent ( "Z" ) ;
490
504
491
- console . log ( woqlObject . json ( ) ) ;
492
-
493
- //const jsonObj={ add_quad: ['doc:x', 'rdfs:myprop', { '@value ': 'my value', '@language': 'en' }, 'db:schema'] }
505
+ const jsonObj = { add_quad : [ 'doc:x' , 'rdfs:subClassOf' , 'scm:Z' , 'db:schema' ] } ;
494
506
495
- // expect(woqlObject.json()).to.eql(jsonObj);
507
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
496
508
497
509
} )
498
510
@@ -510,8 +522,6 @@ describe('triple builder chanier', function () {
510
522
511
523
const woqlObject = WOQL . node ( "doc:x" , "add_quad" ) . relationship ( ) ;
512
524
513
- console . log ( woqlObject . json ( ) ) ;
514
-
515
525
const jsonObj = { add_quad : [ 'doc:x' , 'rdfs:subClassOf' , 'tcs:Entity' , 'db:schema' ] } ;
516
526
517
527
expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
@@ -522,35 +532,86 @@ describe('triple builder chanier', function () {
522
532
523
533
const woqlObject = WOQL . addProperty ( "P" , "string" ) . max ( 4 ) ;
524
534
525
- console . log ( woqlObject . json ( ) ) ;
526
-
527
- //const jsonObj={ add_quad: [ 'doc:x', 'tcs:tag', 'tcs:relationship', 'db:schema' ] };
535
+ const jsonObj = { "and" : [ { "add_quad" : [ "scm:P" ,
536
+ "rdf:type" ,
537
+ "owl:DatatypeProperty" ,
538
+ "db:schema" ] } ,
539
+ { "add_quad" : [ "scm:P" ,
540
+ "rdfs:range" ,
541
+ "xsd:string" ,
542
+ "db:schema" ] } ,
543
+ { "add_quad" : [ "scm:P_max" ,
544
+ "rdf:type" ,
545
+ "owl:Restriction" ,
546
+ "db:schema" ] } ,
547
+ { "add_quad" : [ "scm:P_max" ,
548
+ "owl:onProperty" ,
549
+ "scm:P" ,
550
+ "db:schema" ] } ,
551
+ { "add_quad" : [ "scm:P_max" ,
552
+ "owl:maxCardinality" ,
553
+ { "@value" : "4" , "@type" : "xsd:nonNegativeInteger" } ,
554
+ "db:schema" ] } ] } ;
528
555
529
- // expect(woqlObject.json()).to.eql(jsonObj);
556
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
530
557
531
558
} )
532
559
533
560
it ( 'check the min method' , function ( ) {
534
561
535
562
const woqlObject = WOQL . addProperty ( "P" , "string" ) . min ( 2 ) ;
536
563
537
- console . log ( woqlObject . json ( ) ) ;
564
+ const jsonObj = { "and" : [ { "add_quad" : [ "scm:P" ,
565
+ "rdf:type" ,
566
+ "owl:DatatypeProperty" ,
567
+ "db:schema" ] } ,
568
+ { "add_quad" : [ "scm:P" ,
569
+ "rdfs:range" ,
570
+ "xsd:string" ,
571
+ "db:schema" ] } ,
572
+ { "add_quad" : [ "scm:P_min" ,
573
+ "rdf:type" ,
574
+ "owl:Restriction" ,
575
+ "db:schema" ] } ,
576
+ { "add_quad" : [ "scm:P_min" ,
577
+ "owl:onProperty" ,
578
+ "scm:P" ,
579
+ "db:schema" ] } ,
580
+ { "add_quad" : [ "scm:P_min" ,
581
+ "owl:minCardinality" ,
582
+ { "@value" : "2" , "@type" : "xsd:nonNegativeInteger" } ,
583
+ "db:schema" ] } ] } ;
538
584
539
- //const jsonObj={ add_quad: [ 'doc:x', 'tcs:tag', 'tcs:relationship', 'db:schema' ] };
540
-
541
- //expect(woqlObject.json()).to.eql(jsonObj);
585
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
542
586
543
587
} )
544
588
545
589
it ( 'check the cardinality method' , function ( ) {
546
590
547
591
const woqlObject = WOQL . addProperty ( "P" , "string" ) . cardinality ( 3 ) ;
548
592
549
- console . log ( woqlObject . json ( ) ) ;
550
-
551
- //const jsonObj={ add_quad: [ 'doc:x', 'tcs:tag', 'tcs:relationship', 'db:schema' ] };
593
+ const jsonObj = { "and" : [ { "add_quad" : [ "scm:P" ,
594
+ "rdf:type" ,
595
+ "owl:DatatypeProperty" ,
596
+ "db:schema" ] } ,
597
+ { "add_quad" : [ "scm:P" ,
598
+ "rdfs:range" ,
599
+ "xsd:string" ,
600
+ "db:schema" ] } ,
601
+ { "add_quad" : [ "scm:P_cardinality" ,
602
+ "rdf:type" ,
603
+ "owl:Restriction" ,
604
+ "db:schema" ] } ,
605
+ { "add_quad" : [ "scm:P_cardinality" ,
606
+ "owl:onProperty" ,
607
+ "scm:P" ,
608
+ "db:schema" ] } ,
609
+ { "add_quad" : [ "scm:P_cardinality" ,
610
+ "owl:cardinality" ,
611
+ { "@value" : "3" , "@type" : "xsd:nonNegativeInteger" } ,
612
+ "db:schema" ] } ] } ;
552
613
553
- // expect(woqlObject.json()).to.eql(jsonObj);
614
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
554
615
555
616
} )
556
617
0 commit comments