Skip to content

Commit 10b519c

Browse files
committed
adding more test to woql
1 parent 66131de commit 10b519c

File tree

1 file changed

+40
-34
lines changed

1 file changed

+40
-34
lines changed

test/woql.spec.js

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ describe('woql queries', function () {
4545

4646
const woqlObjectChain=WOQL.not().triple("a", "b", "c");
4747

48-
const jsonObj={ not: [ { triple: [ 'v:a', 'v:b', 'v:c' ] } ] }
48+
//console.log(woqlObject.json());
49+
50+
const jsonObj={ not: [ { triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] } ] }
4951

5052
expect(woqlObject.json()).to.eql(jsonObj);
5153
expect(woqlObjectChain.json()).to.eql(jsonObj);
@@ -56,8 +58,7 @@ describe('woql queries', function () {
5658

5759
const woqlObject=WOQL.and(WOQL.triple("a", "b", "c"),WOQL.triple("1", "2", "3"));
5860

59-
const jsonObj={ and: [ { triple: [ 'v:a', 'v:b', 'v:c' ] },
60-
{ triple: [ 'v:1', 'v:2', 'v:3' ] } ] }
61+
const jsonObj={ and: [ { triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] }, { triple: [ "doc:1", "scm:2", { "@language": "en", "@value": "3" } ] } ] }
6162

6263
expect(woqlObject.json()).to.eql(jsonObj);
6364

@@ -67,23 +68,22 @@ describe('woql queries', function () {
6768

6869
const woqlObject=WOQL.or(WOQL.triple("a", "b", "c"),WOQL.triple("1", "2", "3"));
6970

70-
const jsonObj={ or: [ { triple: [ 'v:a', 'v:b', 'v:c' ] },
71-
{ triple: [ 'v:1', 'v:2', 'v:3' ] } ] }
71+
const jsonObj={ or: [ { triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] },
72+
{ triple: [ "doc:1", "scm:2", { "@language": "en", "@value": "3" } ] } ] }
7273

7374
expect(woqlObject.json()).to.eql(jsonObj);
7475

7576
})
7677

77-
//xfail
7878
it('check the opt method',function(){
7979

8080
const woqlObject=WOQL.opt(WOQL.triple("a", "b", "c"));
8181

8282
const woqlObjectChain=WOQL.opt().triple("a", "b", "c");
8383

84-
const jsonObj={ opt: [ { triple: [ 'v:a', 'v:b', 'v:c' ] } ] }
84+
const jsonObj={ opt: [ { triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] } ] }
8585

86-
//expect(woqlObject.json()).to.eql(jsonObj);
86+
expect(woqlObject.json()).to.eql(jsonObj);
8787
expect(woqlObjectChain.json()).to.eql(jsonObj);
8888

8989
})
@@ -95,8 +95,8 @@ describe('woql queries', function () {
9595
const woqlObjectChain=WOQL.select("V1").triple("a", "b", "c");
9696
const woqlObjectChainMultiple=WOQL.select("V1","V2").triple("a", "b", "c");
9797

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' ] } ] }
98+
const jsonObj={ select: [ 'V1', { triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] } ] }
99+
const jsonObjMultiple={ select: [ 'V1', 'V2', { triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] } ] }
100100

101101
expect(woqlObject.json()).to.eql(jsonObj);
102102
expect(woqlObjectChain.json()).to.eql(jsonObj);
@@ -109,7 +109,7 @@ describe('woql queries', function () {
109109

110110
const woqlObject=WOQL.eq("a","b");
111111

112-
const jsonObj={ eq: [ "v:a", "v:b" ] }
112+
const jsonObj={ eq: [ { "@language": "en", "@value": "a" }, { "@language": "en", "@value": "b" } ] }
113113

114114
expect(woqlObject.json()).to.eql(jsonObj);
115115

@@ -213,7 +213,7 @@ describe('triple builder', function () {
213213

214214
const woqlObject=WOQL.triple("a", "b", "c");
215215

216-
const jsonObj={ triple: [ 'v:a', 'v:b', 'v:c' ] }
216+
const jsonObj={ triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] }
217217

218218
expect(woqlObject.json()).to.eql(jsonObj);
219219

@@ -223,7 +223,7 @@ describe('triple builder', function () {
223223

224224
const woqlObject=WOQL.quad("a", "b", "c", "d");
225225

226-
const jsonObj={ quad: [ 'v:a', 'v:b', 'v:c', 'v:d' ] }
226+
const jsonObj={ quad: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" }, "db:d" ] }
227227

228228
expect(woqlObject.json()).to.eql(jsonObj);
229229

@@ -243,7 +243,7 @@ describe('triple builder', function () {
243243

244244
const woqlObject=WOQL.deleteClass("id");
245245

246-
const jsonObj={ delete_quad: [ 'scm:id', 'rdf:type', 'owl:Class', 'db:schema' ] }
246+
const jsonObj= { and: [ { delete_quad: [ 'scm:id', 'v:All', 'v:Al2', 'db:schema' ] }, { delete_quad: [ 'v:Al3', 'v:Al4', 'scm:id', 'db:schema' ] } ] }
247247

248248
expect(woqlObject.json()).to.eql(jsonObj);
249249

@@ -253,7 +253,7 @@ describe('triple builder', function () {
253253

254254
const woqlObject=WOQL.sub("ClassA","ClassB");
255255

256-
const jsonObj={ sub: [ "v:ClassA", "v:ClassB" ] }
256+
const jsonObj={ sub: [ "scm:ClassA", "scm:ClassB" ] }
257257

258258
expect(woqlObject.json()).to.eql(jsonObj);
259259

@@ -263,17 +263,17 @@ describe('triple builder', function () {
263263

264264
const woqlObject=WOQL.isa("instance","Class");
265265

266-
const jsonObj={ isa: [ "v:instance", "owl:Class" ] }
266+
const jsonObj={ isa: [ "scm:instance", "owl:Class" ] }
267267

268268
expect(woqlObject.json()).to.eql(jsonObj);
269269

270270
})
271271

272272
it('check the delete method',function(){
273273

274-
const woqlObject=WOQL.delete({ triple: [ 'v:a', 'v:b', 'v:c' ] });
274+
const woqlObject=WOQL.delete({ triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] });
275275

276-
const jsonObj={ delete: [ { triple: [ 'v:a', 'v:b', 'v:c' ] } ] }
276+
const jsonObj={ delete: [ { triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] } ] }
277277

278278
expect(woqlObject.json()).to.eql(jsonObj);
279279

@@ -283,7 +283,7 @@ describe('triple builder', function () {
283283

284284
const woqlObject=WOQL.delete_triple("a", "b", "c");
285285

286-
const jsonObj={ delete_triple: [ 'v:a', 'v:b', 'v:c' ] }
286+
const jsonObj={ delete_triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] }
287287

288288
expect(woqlObject.json()).to.eql(jsonObj);
289289

@@ -293,7 +293,7 @@ describe('triple builder', function () {
293293

294294
const woqlObject=WOQL.delete_quad("a", "b", "c", "d");
295295

296-
const jsonObj={ delete_quad: [ 'v:a', 'v:b', 'v:c', 'v:d' ] }
296+
const jsonObj={ delete_quad: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" }, "db:d" ] }
297297

298298
expect(woqlObject.json()).to.eql(jsonObj);
299299

@@ -303,7 +303,7 @@ describe('triple builder', function () {
303303

304304
const woqlObject=WOQL.add_triple("a", "b", "c");
305305

306-
const jsonObj={ add_triple: [ 'v:a', 'v:b', 'v:c' ] }
306+
const jsonObj={ add_triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] }
307307

308308
expect(woqlObject.json()).to.eql(jsonObj);
309309

@@ -313,21 +313,12 @@ describe('triple builder', function () {
313313

314314
const woqlObject=WOQL.add_quad("a", "b", "c", "d");
315315

316-
const jsonObj={ add_quad: [ 'v:a', 'v:b', 'v:c', 'v:d' ] }
316+
const jsonObj={ add_quad: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" }, "db:d" ] }
317317

318318
expect(woqlObject.json()).to.eql(jsonObj);
319319

320320
})
321321

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-
})
331322

332323
it('check the addProperty method',function(){
333324
//{ limit: [ 10, { start: [Array] } ] }
@@ -342,10 +333,25 @@ describe('triple builder', function () {
342333
it('check the deleteProperty method',function(){
343334
//{ limit: [ 10, { start: [Array] } ] }
344335
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' ] }
347336

348-
//expect(woqlObject.json()).to.eql(jsonObj);
337+
const jsonObj={ and: [ { delete_quad: [ 'scm:some_property', 'v:All', 'v:Al2', 'xsd:string' ] }, { delete_quad: [ 'v:Al3', 'v:Al4', 'scm:some_property', 'xsd:string' ] } ] }
338+
339+
expect(woqlObject.json()).to.eql(jsonObj);
340+
341+
})
342+
343+
})
344+
345+
346+
describe('triple builder chanier', function () {
347+
348+
it('check the node method',function(){
349+
350+
const woqlObject=WOQL.node("some_node");
351+
352+
const jsonObj={}
353+
354+
expect(woqlObject.json()).to.eql(jsonObj);
349355

350356
})
351357

0 commit comments

Comments
 (0)