Skip to content

Commit d19642f

Browse files
committed
add more tests in for woql.js
1 parent 4b9da26 commit d19642f

File tree

1 file changed

+76
-2
lines changed

1 file changed

+76
-2
lines changed

test/woql.spec.js

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,63 @@ describe('woql queries', function () {
7575

7676
})
7777

78+
it('check the when method',function(){
79+
80+
const Update=WOQL.addClass("id");
81+
const Condition=WOQL.or(WOQL.triple("a", "b", "c"),WOQL.triple("1", "2", "3"));
82+
83+
const woqlObject=WOQL.when(Condition, Update);
84+
85+
const woqlObjectChain=WOQL.when(Condition).addClass("id")
86+
//console.log(woqlObject.json()['when'][0][]);
87+
console.log(woqlObjectChain.json());
88+
/*
89+
const jsonObj={
90+
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]
98+
},
99+
{}
100+
]
101+
};
102+
*/
103+
//expect(woqlObject.json()).to.eql(jsonObj);
104+
//expect(woqlObjectChain.json()).to.eql(jsonObj);
105+
106+
})
107+
78108
it('check the opt method',function(){
79109

80110
const woqlObject=WOQL.opt(WOQL.triple("a", "b", "c"));
81111

82-
//const woqlObjectChain=WOQL.opt().triple("a", "b", "c");
112+
const woqlObjectChain=WOQL.opt().triple("a", "b", "c");
83113

84114
const jsonObj={ opt: [ { triple: [ "doc:a", "scm:b", { "@language": "en", "@value": "c" } ] } ] }
85115

86116
expect(woqlObject.json()).to.eql(jsonObj);
87-
//expect(woqlObjectChain.json()).to.eql(jsonObj);
117+
expect(woqlObjectChain.json()).to.eql(jsonObj);
88118

89119
})
90120

121+
it('check the from method',function(){
122+
123+
const Query=WOQL.limit(10);
124+
//const woqlObject=WOQL.from("http://dburl", Query);
125+
126+
const woqlObjectChain=WOQL.from("http://dburl").limit(10);
127+
128+
const jsonObj={ from: [ 'http://dburl', { limit: [ 10, {} ] } ] }
129+
130+
//expect(woqlObject.json()).to.eql(jsonObj);
131+
expect(woqlObjectChain.json()).to.eql(jsonObj);
132+
133+
})
134+
91135
it('check the select method',function(){
92136

93137
const woqlObject=WOQL.select("V1", WOQL.triple("a", "b", "c"));
@@ -185,6 +229,16 @@ describe('woql queries', function () {
185229

186230
})
187231

232+
it('check the get method',function(){
233+
234+
const woqlObject=WOQL.as("Map", "Target");
235+
236+
const jsonObj={ as: [ { '@value': 'Map' }, 'v:Target' ] };
237+
238+
expect(woqlObject.json()).to.eql(jsonObj);
239+
240+
})
241+
188242
it('check the as method',function(){
189243

190244
const woqlObject=WOQL.as("Source", "Target");
@@ -195,6 +249,16 @@ describe('woql queries', function () {
195249

196250
})
197251

252+
it('check the remote method',function(){
253+
254+
const woqlObject=WOQL.remote({url: "http://url"});
255+
console.log(woqlObject.json());
256+
//const jsonObj={ as: [ { '@value': 'Prefix' }, 'v:V1,V2' ] };
257+
258+
//expect(woqlObject.json()).to.eql(jsonObj);
259+
260+
})
261+
198262
it('check the unique method',function(){
199263

200264
const woqlObject=WOQL.as("Prefix", ["V1","V2"]);
@@ -205,6 +269,16 @@ describe('woql queries', function () {
205269

206270
})
207271

272+
it('check the list method',function(){
273+
274+
const woqlObject=WOQL.list(["V1","V2"]);
275+
console.log(woqlObject.json());
276+
//const jsonObj={ as: [ { '@value': 'Prefix' }, 'v:V1,V2' ] };
277+
278+
//expect(woqlObject.json()).to.eql(jsonObj);
279+
280+
})
281+
208282
})
209283

210284
describe('triple builder', function () {

0 commit comments

Comments
 (0)