Browse Source

tests for where clause

pull/8/head
oof1lab 7 years ago
parent
commit
ee3d65e17e
  1. 2
      README.md
  2. 4
      lib/xapi.js
  3. 87
      tests/tests.js

2
README.md

@ -288,7 +288,7 @@ http://localhost:3000/download?name=fileName
## When NOT to use ? ## When NOT to use ?
* If you are in need of a full blown MVC framework, ACL, Authorisation etc - Not this. * If you are in need of a full blown MVC framework, ACL, Authorisation etc - Not this.
* Other times not mentioned in when to use section * Other times not mentioned in when to use section
### Command line options ### Command line options

4
lib/xapi.js

@ -194,10 +194,7 @@ class Xapi {
this.app.get('/download', this.downloadFile.bind(this)); this.app.get('/download', this.downloadFile.bind(this));
/**************** END : multer routes ****************/ /**************** END : multer routes ****************/
} }
} }
async create(req, res) { async create(req, res) {
@ -502,7 +499,6 @@ class Xapi {
uploadFiles(req, res) { uploadFiles(req, res) {
if (!req.files || req.files.length === 0) { if (!req.files || req.files.length === 0) {
res.end('upload failed') res.end('upload failed')
} else { } else {

87
tests/tests.js

@ -1009,28 +1009,73 @@ 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 query = ''
// var params = [] var params = []
// var err = whereClause.getWhereClause('((a,eq,1)+and(b,eq,2))+or(c,eq,3)',query,params) var err = whereClause.getWhereClause('((abc,eq,1234)+and(b,eq,2))+or(cde,eq,3)',query,params)
//
// err.err.should.be.equal(0) err.err.should.be.equal(0)
// err.query.should.be.equal('((??=?)and(??=?))or(??=?)') err.query.should.be.equal('((??=?)and(??=?))or(??=?)')
// err.params.length.should.be.equal(4) err.params.length.should.be.equal(6)
// err.params[0].should.be.equal('abc')
// err.params[1].should.be.equal('1') err.params[0].should.be.equal('abc')
// err.params[2].should.be.equal('b') err.params[2].should.be.equal('b')
// err.params[3].should.be.equal('2') err.params[4].should.be.equal('cde')
//
// err.params[1].should.be.equal('1234') err.params[1].should.be.equal('1234')
// err.params[3].should.be.equal('2')
// done() err.params[5].should.be.equal('3')
//
// //console.log(query,params,err); 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)
err.err.should.be.equal(0)
err.query.should.be.equal('((??=?)and(??=?))xor(??=?)')
err.params.length.should.be.equal(6)
err.params[0].should.be.equal('abc')
err.params[2].should.be.equal('b')
err.params[4].should.be.equal('cde')
err.params[1].should.be.equal('1234')
err.params[3].should.be.equal('2')
err.params[5].should.be.equal('3')
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)
err.err.should.be.equal(0)
err.query.should.be.equal('(??=?)and((??=?)or(??=?))')
err.params.length.should.be.equal(6)
err.params[0].should.be.equal('a')
err.params[2].should.be.equal('b')
err.params[4].should.be.equal('c')
err.params[1].should.be.equal('1')
err.params[3].should.be.equal('2')
err.params[5].should.be.equal('3')
done()
});

Loading…
Cancel
Save