@ -504,6 +504,88 @@ describe('xmysql : tests', function () {
} ) ;
} ) ;
it ( 'GET /api/offices/1/employees?_where=(jobTitle,eq,Sales%20Rep) should PASS' , function ( done ) {
//post to an url with data
agent . get ( '/api/offices/1/employees?_where=(jobTitle,eq,Sales%20Rep)' ) //enter url
. expect ( 200 ) //200 for success 4xx for failure
. end ( function ( err , res ) {
// Handle /api/v error
if ( err ) {
return done ( err ) ;
}
//validate response
res . body . length . should . be . equals ( 2 )
return done ( ) ;
} ) ;
} ) ;
it ( 'GET /api/payments?_where=(amount,gte,1000)~and(customerNumber,lte,120) should PASS' , function ( done ) {
//post to an url with data
agent . get ( '/api/payments?_where=(amount,gte,1000)~and(customerNumber,lte,120)' ) //enter url
. expect ( 200 ) //200 for success 4xx for failure
. end ( function ( err , res ) {
// Handle /api/v error
if ( err ) {
return done ( err ) ;
}
//validate response
res . body . length . should . be . equals ( 13 )
return done ( ) ;
} ) ;
} ) ;
it ( 'GET /api/payments?_where=(amount,gte,1000)&_sort=-amount should PASS' , function ( done ) {
//post to an url with data
agent . get ( '/api/payments?_where=(amount,gte,1000)&_sort=-amount' ) //enter url
. expect ( 200 ) //200 for success 4xx for failure
. end ( function ( err , res ) {
// Handle /api/v error
if ( err ) {
return done ( err ) ;
}
//validate response
res . body [ 0 ] . amount . should . be . equals ( 120166.58 )
return done ( ) ;
} ) ;
} ) ;
http : //localhost:3000/api/payments?_where=(checkNumber,eq,JM555205)~or(checkNumber,eq,OM314933)
it ( 'GET /api/payments?_where=(checkNumber,eq,JM555205)~or(checkNumber,eq,OM314933) should PASS' , function ( done ) {
//post to an url with data
agent . get ( '/api/payments?_where=(checkNumber,eq,JM555205)~or(checkNumber,eq,OM314933)' ) //enter url
. expect ( 200 ) //200 for success 4xx for failure
. end ( function ( err , res ) {
// Handle /api/v error
if ( err ) {
return done ( err ) ;
}
//validate response
res . body . length . should . be . equals ( 2 )
return done ( ) ;
} ) ;
} ) ;
it ( 'GET /api/employees/1002/employees should PASS' , function ( done ) {
//post to an url with data
@ -753,7 +835,7 @@ describe('xmysql : tests', function () {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,eq,1234)' , query , params )
var err = whereClause . getWhereClause ( '(abc,eq,1234)' )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(??=?)' )
@ -771,7 +853,7 @@ describe('xmysql : tests', function () {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,ne,1234)' , query , params )
var err = whereClause . getWhereClause ( '(abc,ne,1234)' )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(??!=?)' )
@ -789,7 +871,7 @@ describe('xmysql : tests', function () {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,lt,1234)' , query , params )
var err = whereClause . getWhereClause ( '(abc,lt,1234)' )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(??<?)' )
@ -806,7 +888,7 @@ describe('xmysql : tests', function () {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,lte,1234)' , query , params )
var err = whereClause . getWhereClause ( '(abc,lte,1234)' )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(??<=?)' )
@ -823,7 +905,7 @@ describe('xmysql : tests', function () {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,gt,1234)' , query , params )
var err = whereClause . getWhereClause ( '(abc,gt,1234)' )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(??>?)' )
@ -840,7 +922,7 @@ describe('xmysql : tests', function () {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,gte,1234)' , query , params )
var err = whereClause . getWhereClause ( '(abc,gte,1234)' )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(??>=?)' )
@ -854,46 +936,46 @@ describe('xmysql : tests', function () {
} ) ;
it ( 'where clause unit ?_where=(abc,like,1234) should PASS', function ( done ) {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,like,1234)' , query , params )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(?? like ?)' )
err . params [ 0 ] . should . be . equal ( 'abc' )
err . params [ 1 ] . should . be . equal ( '1234' )
done ( )
//console.log(query,params,err);
} ) ;
it ( 'where clause unit ?_where=(abc,nlike,1234) should PASS', function ( done ) {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,nlike,1234)' , query , params )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(?? not like ?)' )
err . params [ 0 ] . should . be . equal ( 'abc' )
err . params [ 1 ] . should . be . equal ( '1234' )
done ( )
//console.log(query,params,err);
} ) ;
// it( 'where clause unit ?_where=(abc,like,1234) should PASS', function (done) {
//
// var query = ''
// var params = []
// var err = whereClause.getWhereClause('(abc,like,1234)')
//
// err.err.should.be.equal(0)
// err.query.should.be.equal('(?? like ?)')
// err.params[0].should.be.equal('abc')
// err.params[1].should.be.equal('1234')
//
// done()
//
// //console.log(query,params,err);
//
// });
//
//
// it( 'where clause unit ?_where=(abc,nlike,1234) should PASS', function (done) {
//
// var query = ''
// var params = []
// var err = whereClause.getWhereClause('(abc,nlike,1234)')
//
// err.err.should.be.equal(0)
// err.query.should.be.equal('(?? not like ?)')
// err.params[0].should.be.equal('abc')
// err.params[1].should.be.equal('1234')
//
// done()
//
// //console.log(query,params,err);
//
// });
it ( 'where clause unit ?_where=abc,eq,1234) should FAIL' , function ( done ) {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( 'abc,eq,1234)' , query , params )
var err = whereClause . getWhereClause ( 'abc,eq,1234)' )
err . err . should . be . equal ( 1 )
err . query . should . be . equal ( '' )
@ -909,7 +991,7 @@ describe('xmysql : tests', function () {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,eq,1234' , query , params )
var err = whereClause . getWhereClause ( '(abc,eq,1234' )
err . err . should . be . equal ( 1 )
err . query . should . be . equal ( '' )
@ -925,7 +1007,7 @@ describe('xmysql : tests', function () {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,eq1234)' , query , params )
var err = whereClause . getWhereClause ( '(abc,eq1234)' )
err . err . should . be . equal ( 1 )
err . query . should . be . equal ( '' )
@ -941,7 +1023,7 @@ describe('xmysql : tests', function () {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abceq,1234)' , query , params )
var err = whereClause . getWhereClause ( '(abceq,1234)' )
err . err . should . be . equal ( 1 )
err . query . should . be . equal ( '' )
@ -954,11 +1036,11 @@ describe('xmysql : tests', function () {
} ) ;
it ( 'where clause unit ?_where=(1,eq,1)(1,eq,2)+ or should FAIL' , function ( done ) {
it ( 'where clause unit ?_where=(1,eq,1)(1,eq,2)~ or should FAIL' , function ( done ) {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(1,eq,1)(1,eq,2)+or' , query , params )
var err = whereClause . getWhereClause ( '(1,eq,1)(1,eq,2)~or' )
err . err . should . be . equal ( 1 )
err . query . should . be . equal ( '' )
@ -970,11 +1052,11 @@ describe('xmysql : tests', function () {
} ) ;
it ( 'where clause unit ?_where=(1,eq,1)+or+ or(1,eq,2)(1,eq,2) should FAIL' , function ( done ) {
it ( 'where clause unit ?_where=(1,eq,1)~or~ or(1,eq,2)(1,eq,2) should FAIL' , function ( done ) {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(1,eq,1)+or+or(1,eq,2)(1,eq,2)' , query , params )
var err = whereClause . getWhereClause ( '(1,eq,1)~or~or(1,eq,2)(1,eq,2)' )
err . err . should . be . equal ( 1 )
err . query . should . be . equal ( '' )
@ -986,11 +1068,11 @@ describe('xmysql : tests', function () {
} ) ;
it ( 'where clause unit ?_where=(abc,eq,1)+ or(b,eq,2) should PASS' , function ( done ) {
it ( 'where clause unit ?_where=(abc,eq,1)~ or(b,eq,2) should PASS' , function ( done ) {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(abc,eq,1)+or(b,eq,2)' , query , params )
var err = whereClause . getWhereClause ( '(abc,eq,1)~or(b,eq,2)' )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(??=?)or(??=?)' )
@ -1009,11 +1091,11 @@ describe('xmysql : tests', function () {
} ) ;
it ( 'where clause unit ?_where=((a,eq,1)+and(b,eq,2))+ or(c,eq,3) should PASS' , function ( done ) {
it ( 'where clause unit ?_where=((a,eq,1)~and(b,eq,2))~ or(c,eq,3) should PASS' , function ( done ) {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '((abc,eq,1234)+and(b,eq,2))+or(cde,eq,3)' , query , params )
var err = whereClause . getWhereClause ( '((abc,eq,1234)~and(b,eq,2))~or(cde,eq,3)' )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '((??=?)and(??=?))or(??=?)' )
@ -1032,11 +1114,11 @@ describe('xmysql : tests', function () {
} ) ;
it ( 'where clause unit ?_where=((a,eq,1)+and(b,eq,2))+ xor(c,eq,3) should PASS' , function ( done ) {
it ( 'where clause unit ?_where=((a,eq,1)~and(b,eq,2))~ xor(c,eq,3) should PASS' , function ( done ) {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '((abc,eq,1234)+and(b,eq,2))+xor(cde,eq,3)' , query , params )
var err = whereClause . getWhereClause ( '((abc,eq,1234)~and(b,eq,2))~xor(cde,eq,3)' )
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '((??=?)and(??=?))xor(??=?)' )
@ -1055,11 +1137,13 @@ describe('xmysql : tests', function () {
} ) ;
it ( 'where clause unit ?_where=(a,eq,1)+and((b,eq,2)+ or(c,eq,3)) should PASS' , function ( done ) {
it ( 'where clause unit ?_where=(a,eq,1)~and((b,eq,2)~ or(c,eq,3)) should PASS' , function ( done ) {
var query = ''
var params = [ ]
var err = whereClause . getWhereClause ( '(a,eq,1)+and((b,eq,2)+or(c,eq,3))' , query , params )
var err = whereClause . getWhereClause ( '(a,eq,1)~and((b,eq,2)~or(c,eq,3))' )
//console.log(query,params);
err . err . should . be . equal ( 0 )
err . query . should . be . equal ( '(??=?)and((??=?)or(??=?))' )