@@ -22,28 +22,331 @@ describe('woql queries', function () {
22
22
it ( 'check the limit method' , function ( ) {
23
23
24
24
const woqlObject = WOQL . limit ( 10 ) ;
25
- //{ limit: [ 10, {} ] }
26
-
27
- //console.log(woqlObject.json());
28
25
29
26
expect ( woqlObject . json ( ) . limit [ 0 ] ) . to . equal ( 10 ) ;
30
27
31
- //chai.should(woqlObject.json()).jsonEqual({ limit: [ 10, {} ] });
32
-
33
28
expect ( woqlObject . json ( ) ) . to . eql ( { limit : [ 10 , { } ] } ) ;
34
29
35
30
} )
36
31
37
32
it ( 'check the start method' , function ( ) {
38
- //{ limit: [ 10, { start: [Array] } ] }
33
+
39
34
const woqlObject = WOQL . limit ( 10 ) . start ( 0 ) ;
40
35
41
36
const jsonObj = { "limit" : [ 10 , { "start" : [ 0 , { } ] } ] }
42
37
43
- //console.log(JSON.stringify(woqlObject.json(),null,2))
38
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
39
+
40
+ } )
41
+
42
+ it ( 'check the not method' , function ( ) {
43
+
44
+ const woqlObject = WOQL . not ( WOQL . triple ( "a" , "b" , "c" ) ) ;
45
+
46
+ const woqlObjectChain = WOQL . not ( ) . triple ( "a" , "b" , "c" ) ;
47
+
48
+ const jsonObj = { not : [ { triple : [ 'v:a' , 'v:b' , 'v:c' ] } ] }
44
49
45
50
expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
51
+ expect ( woqlObjectChain . json ( ) ) . to . eql ( jsonObj ) ;
46
52
47
53
} )
48
54
49
- } )
55
+ it ( 'check the and method' , function ( ) {
56
+
57
+ const woqlObject = WOQL . and ( WOQL . triple ( "a" , "b" , "c" ) , WOQL . triple ( "1" , "2" , "3" ) ) ;
58
+
59
+ const jsonObj = { and : [ { triple : [ 'v:a' , 'v:b' , 'v:c' ] } ,
60
+ { triple : [ 'v:1' , 'v:2' , 'v:3' ] } ] }
61
+
62
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
63
+
64
+ } )
65
+
66
+ it ( 'check the or method' , function ( ) {
67
+
68
+ const woqlObject = WOQL . or ( WOQL . triple ( "a" , "b" , "c" ) , WOQL . triple ( "1" , "2" , "3" ) ) ;
69
+
70
+ const jsonObj = { or : [ { triple : [ 'v:a' , 'v:b' , 'v:c' ] } ,
71
+ { triple : [ 'v:1' , 'v:2' , 'v:3' ] } ] }
72
+
73
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
74
+
75
+ } )
76
+
77
+ //xfail
78
+ it ( 'check the opt method' , function ( ) {
79
+
80
+ const woqlObject = WOQL . opt ( WOQL . triple ( "a" , "b" , "c" ) ) ;
81
+
82
+ const woqlObjectChain = WOQL . opt ( ) . triple ( "a" , "b" , "c" ) ;
83
+
84
+ const jsonObj = { opt : [ { triple : [ 'v:a' , 'v:b' , 'v:c' ] } ] }
85
+
86
+ //expect(woqlObject.json()).to.eql(jsonObj);
87
+ expect ( woqlObjectChain . json ( ) ) . to . eql ( jsonObj ) ;
88
+
89
+ } )
90
+
91
+ it ( 'check the select method' , function ( ) {
92
+
93
+ const woqlObject = WOQL . select ( "V1" , WOQL . triple ( "a" , "b" , "c" ) ) ;
94
+ const woqlObjectMultiple = WOQL . select ( "V1" , "V2" , WOQL . triple ( "a" , "b" , "c" ) ) ;
95
+ const woqlObjectChain = WOQL . select ( "V1" ) . triple ( "a" , "b" , "c" ) ;
96
+ const woqlObjectChainMultiple = WOQL . select ( "V1" , "V2" ) . triple ( "a" , "b" , "c" ) ;
97
+
98
+ const jsonObj = { select : [ 'V1' , { triple : [ 'v:a' , 'v:b' , 'v:c' ] } ] }
99
+ const jsonObjMultiple = { select : [ 'V1' , 'V2' , { triple : [ 'v:a' , 'v:b' , 'v:c' ] } ] }
100
+
101
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
102
+ expect ( woqlObjectChain . json ( ) ) . to . eql ( jsonObj ) ;
103
+ expect ( woqlObjectMultiple . json ( ) ) . to . eql ( jsonObjMultiple ) ;
104
+ expect ( woqlObjectChainMultiple . json ( ) ) . to . eql ( jsonObjMultiple ) ;
105
+
106
+ } )
107
+
108
+ it ( 'check the eq method' , function ( ) {
109
+
110
+ const woqlObject = WOQL . eq ( "a" , "b" ) ;
111
+
112
+ const jsonObj = { eq : [ "v:a" , "v:b" ] }
113
+
114
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
115
+
116
+ } )
117
+
118
+ it ( 'check the trim method' , function ( ) {
119
+
120
+ const woqlObject = WOQL . trim ( "a" , "b" ) ;
121
+
122
+ const jsonObj = { trim : [ "a" , "b" ] }
123
+
124
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
125
+
126
+ } )
127
+
128
+ it ( 'check the eval method' , function ( ) {
129
+
130
+ const woqlObject = WOQL . eval ( "1+2" , "b" ) ;
131
+
132
+ const jsonObj = { eval : [ '1+2' , 'b' ] }
133
+
134
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
135
+
136
+ } )
137
+
138
+ it ( 'check the minus method' , function ( ) {
139
+
140
+ const woqlObject = WOQL . minus ( "2" , "1" ) ;
141
+
142
+ const jsonObj = { minus : [ '2' , '1' ] }
143
+
144
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
145
+
146
+ } )
147
+
148
+ it ( 'check the plus method' , function ( ) {
149
+
150
+ const woqlObject = WOQL . plus ( "2" , "1" ) ;
151
+
152
+ const jsonObj = { plus : [ '2' , '1' ] }
153
+
154
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
155
+
156
+ } )
157
+
158
+ it ( 'check the times method' , function ( ) {
159
+
160
+ const woqlObject = WOQL . times ( "2" , "1" ) ;
161
+
162
+ const jsonObj = { times : [ '2' , '1' ] }
163
+
164
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
165
+
166
+ } )
167
+
168
+ it ( 'check the divide method' , function ( ) {
169
+
170
+ const woqlObject = WOQL . divide ( "2" , "1" ) ;
171
+
172
+ const jsonObj = { divide : [ '2' , '1' ] }
173
+
174
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
175
+
176
+ } )
177
+
178
+ it ( 'check the exp method' , function ( ) {
179
+
180
+ const woqlObject = WOQL . exp ( "2" , "1" ) ;
181
+
182
+ const jsonObj = { exp : [ '2' , '1' ] }
183
+
184
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
185
+
186
+ } )
187
+
188
+ it ( 'check the as method' , function ( ) {
189
+
190
+ const woqlObject = WOQL . as ( "Source" , "Target" ) ;
191
+
192
+ const jsonObj = { as : [ { '@value' : 'Source' } , 'v:Target' ] }
193
+
194
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
195
+
196
+ } )
197
+
198
+ it ( 'check the unique method' , function ( ) {
199
+
200
+ const woqlObject = WOQL . as ( "Prefix" , [ "V1" , "V2" ] ) ;
201
+
202
+ const jsonObj = { as : [ { '@value' : 'Prefix' } , 'v:V1,V2' ] }
203
+
204
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
205
+
206
+ } )
207
+
208
+ } )
209
+
210
+ describe ( 'triple builder' , function ( ) {
211
+
212
+ it ( 'check the triple method' , function ( ) {
213
+
214
+ const woqlObject = WOQL . triple ( "a" , "b" , "c" ) ;
215
+
216
+ const jsonObj = { triple : [ 'v:a' , 'v:b' , 'v:c' ] }
217
+
218
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
219
+
220
+ } )
221
+
222
+ it ( 'check the quad method' , function ( ) {
223
+
224
+ const woqlObject = WOQL . quad ( "a" , "b" , "c" , "d" ) ;
225
+
226
+ const jsonObj = { quad : [ 'v:a' , 'v:b' , 'v:c' , 'v:d' ] }
227
+
228
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
229
+
230
+ } )
231
+
232
+ it ( 'check the addClass method' , function ( ) {
233
+
234
+ const woqlObject = WOQL . addClass ( "id" ) ;
235
+
236
+ const jsonObj = { add_quad : [ 'scm:id' , 'rdf:type' , 'owl:Class' , 'db:schema' ] }
237
+
238
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
239
+
240
+ } )
241
+
242
+ it ( 'check the deleteClass method' , function ( ) {
243
+
244
+ const woqlObject = WOQL . deleteClass ( "id" ) ;
245
+
246
+ const jsonObj = { delete_quad : [ 'scm:id' , 'rdf:type' , 'owl:Class' , 'db:schema' ] }
247
+
248
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
249
+
250
+ } )
251
+
252
+ it ( 'check the sub method' , function ( ) {
253
+
254
+ const woqlObject = WOQL . sub ( "ClassA" , "ClassB" ) ;
255
+
256
+ const jsonObj = { sub : [ "v:ClassA" , "v:ClassB" ] }
257
+
258
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
259
+
260
+ } )
261
+
262
+ it ( 'check the isa method' , function ( ) {
263
+
264
+ const woqlObject = WOQL . isa ( "instance" , "Class" ) ;
265
+
266
+ const jsonObj = { isa : [ "v:instance" , "owl:Class" ] }
267
+
268
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
269
+
270
+ } )
271
+
272
+ it ( 'check the delete method' , function ( ) {
273
+
274
+ const woqlObject = WOQL . delete ( { triple : [ 'v:a' , 'v:b' , 'v:c' ] } ) ;
275
+
276
+ const jsonObj = { delete : [ { triple : [ 'v:a' , 'v:b' , 'v:c' ] } ] }
277
+
278
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
279
+
280
+ } )
281
+
282
+ it ( 'check the delete_triple method' , function ( ) {
283
+
284
+ const woqlObject = WOQL . delete_triple ( "a" , "b" , "c" ) ;
285
+
286
+ const jsonObj = { delete_triple : [ 'v:a' , 'v:b' , 'v:c' ] }
287
+
288
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
289
+
290
+ } )
291
+
292
+ it ( 'check the delete_quard method' , function ( ) {
293
+
294
+ const woqlObject = WOQL . delete_quad ( "a" , "b" , "c" , "d" ) ;
295
+
296
+ const jsonObj = { delete_quad : [ 'v:a' , 'v:b' , 'v:c' , 'v:d' ] }
297
+
298
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
299
+
300
+ } )
301
+
302
+ it ( 'check the add_triple method' , function ( ) {
303
+
304
+ const woqlObject = WOQL . add_triple ( "a" , "b" , "c" ) ;
305
+
306
+ const jsonObj = { add_triple : [ 'v:a' , 'v:b' , 'v:c' ] }
307
+
308
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
309
+
310
+ } )
311
+
312
+ it ( 'check the add_quard method' , function ( ) {
313
+
314
+ const woqlObject = WOQL . add_quad ( "a" , "b" , "c" , "d" ) ;
315
+
316
+ const jsonObj = { add_quad : [ 'v:a' , 'v:b' , 'v:c' , 'v:d' ] }
317
+
318
+ expect ( woqlObject . json ( ) ) . to . eql ( jsonObj ) ;
319
+
320
+ } )
321
+
322
+ it ( 'check the node method' , function ( ) {
323
+ //{ limit: [ 10, { start: [Array] } ] }
324
+ //const woqlObject=WOQL.node("some_node");
325
+ //console.log(woqlObject.json())
326
+ //const jsonObj={ add_quad: [ 'scm:id', 'rdf:type', 'owl:Class', 'db:schema' ] }
327
+
328
+ //expect(woqlObject.json()).to.eql(jsonObj);
329
+
330
+ } )
331
+
332
+ it ( 'check the addProperty method' , function ( ) {
333
+ //{ limit: [ 10, { start: [Array] } ] }
334
+ const woqlObject = WOQL . addProperty ( "some_property" , "string" ) ;
335
+ console . log ( woqlObject . json ( ) )
336
+ //const jsonObj={ add_quad: [ 'scm:some_property', 'rdf:scm', 'owl:Class', 'db:schema' ] }
337
+
338
+ //expect(woqlObject.json()).to.eql(jsonObj);
339
+
340
+ } )
341
+
342
+ it ( 'check the deleteProperty method' , function ( ) {
343
+ //{ limit: [ 10, { start: [Array] } ] }
344
+ const woqlObject = WOQL . deleteProperty ( "some_property" , "string" ) ;
345
+ console . log ( woqlObject . json ( ) )
346
+ //const jsonObj={ add_quad: [ 'scm:some_property', 'rdf:scm', 'owl:Class', 'db:schema' ] }
347
+
348
+ //expect(woqlObject.json()).to.eql(jsonObj);
349
+
350
+ } )
351
+
352
+ } )
0 commit comments