File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -86,9 +86,9 @@ WOQLQuery.prototype.boolean = function (tf) {
8686} ;
8787
8888/**
89- * @param {any } s
90- * @param {string } t
91- * @returns {object }
89+ * @param {any } s - the value of the literal
90+ * @param {string } t - the type of the literal, e.g. 'xsd:string', 'xsd:boolean'
91+ * @returns {object } - a WOQL DataValue object with the given type and value
9292 */
9393WOQLQuery . prototype . literal = function ( s , t ) {
9494 t = t . indexOf ( ':' ) === - 1 ? `xsd:${ t } ` : t ;
Original file line number Diff line number Diff line change 1+ const { expect } = require ( 'chai' ) ;
2+ const WOQL = require ( '../lib/woql' ) ;
3+
4+ describe ( 'WOQL.literal() tests' , ( ) => {
5+ it ( 'should correctly wrap literal value 0 with xsd:double in DataValue structure' , ( ) => {
6+ const result = WOQL . eq ( "v:var" , WOQL . literal ( 0 , 'xsd:double' ) ) ;
7+
8+ const expected = {
9+ '@type' : 'Equals' ,
10+ 'left' : {
11+ '@type' : 'Value' ,
12+ 'variable' : 'var'
13+ } ,
14+ 'right' : {
15+ '@type' : 'Value' ,
16+ 'data' : {
17+ '@type' : 'xsd:double' ,
18+ '@value' : 0
19+ }
20+ }
21+ } ;
22+
23+ expect ( result . query ) . to . eql ( expected ) ;
24+ } ) ;
25+ } ) ;
You can’t perform that action at this time.
0 commit comments