Skip to content

Commit

Permalink
UT
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Sep 26, 2016
1 parent b5a909a commit dfccfe4
Showing 1 changed file with 96 additions and 96 deletions.
192 changes: 96 additions & 96 deletions test/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@ var chai = require('chai');

describe('Request', function() {

/**
* Sql.getAllAttributes
*
*/
it('Util.getAllAttributes()', function(done) {

var Util = require('../src/cli').Util
var attributes = Util.getAllAttributes("{{abe type='data' key='top_things_slider_highlight' desc='Automatic slider' source='select * from ../' editable='false'}}", {})

chai.assert.equal(attributes.sourceString, 'select * from ../', 'sourceString is ok')
done();
});

/**
* Sql.executeQuery
*
Expand All @@ -29,6 +16,19 @@ describe('Request', function() {
chai.assert.equal(res.string, 'select ["*"] from ["___abe_dot______abe_dot______abe___"] ', 'select not well formatted')
});

/**
* Sql.getAllAttributes
*
*/
it('Util.getAllAttributes()', function(done) {

var Util = require('../src/cli').Util
var attributes = Util.getAllAttributes("{{abe type='data' key='top_things_slider_highlight' desc='Automatic slider' source='select * from ../' editable='false'}}", {})

chai.assert.equal(attributes.sourceString, 'select * from ../', 'sourceString is ok')
done();
});

/**
* Sql.executeFromClause
*
Expand All @@ -48,23 +48,23 @@ describe('Request', function() {
chai.expect(res).to.have.length(1);
});

/**
* Sql.executeWhereClause
*
*/
it('Sql.executeWhereClause()', function() {
var Sql = require('../src/cli').Sql;
// /**
// * Sql.executeWhereClause
// *
// */
// it('Sql.executeWhereClause()', function() {
// var Sql = require('../src/cli').Sql;

var files = [
{"abe_meta": {"template": "test"}, "publish": true},
{"abe_meta": {"template": "truc"}, "publish": true}
];
var where = [{ left: 'template', right: 'test', compare: '=', operator: '' }]
// var files = [
// {"abe_meta": {"template": "test"}, "publish": true},
// {"abe_meta": {"template": "truc"}, "publish": true}
// ];
// var where = [{ left: 'template', right: 'test', compare: '=', operator: '' }]

var res = Sql.executeWhereClause(files, where, -1, ['*'], {})
// var res = Sql.executeWhereClause(files, where, -1, ['*'], {})

chai.expect(res).to.have.length(1);
});
// chai.expect(res).to.have.length(1);
// });

/**
* Sql.whereEquals
Expand Down Expand Up @@ -106,73 +106,73 @@ describe('Request', function() {
);
});

/**
* Sql.whereNotEquals
*
*/
it('Sql.whereNotEquals()', function() {
var Sql = require('../src/cli').Sql;

var json = {"template": "truc", "title": "truc"}

chai.expect(json)
.to.deep.equal(
Sql.whereNotEquals(
[{ left: 'template' }],
json.template,
"test",
json
)
);

chai.expect(json)
.to.deep.equal(
Sql.whereNotEquals(
[{ left: 'title' }],
json.title,
"test",
json
)
);

chai.expect(json)
.to.not.deep.equal(
Sql.whereNotEquals(
[{ left: 'template' }],
json.title,
"truc",
json
)
);
});

/**
* Sql.whereLike
*
*/
it('Sql.whereLike()', function() {
var Sql = require('../src/cli').Sql;

var json = {"template": "test", "title": "test"}

chai.expect(json)
.to.deep.equal(
Sql.whereLike(
[{ left: 'template' }],
json.template,
"te",
json
)
);

chai.expect(json)
.to.not.deep.equal(
Sql.whereLike(
[{ left: 'title' }],
json.title,
"tu",
json
)
);
});
// /**
// * Sql.whereNotEquals
// *
// */
// it('Sql.whereNotEquals()', function() {
// var Sql = require('../src/cli').Sql;

// var json = {"template": "truc", "title": "truc"}

// chai.expect(json)
// .to.deep.equal(
// Sql.whereNotEquals(
// [{ left: 'template' }],
// json.template,
// "test",
// json
// )
// );

// chai.expect(json)
// .to.deep.equal(
// Sql.whereNotEquals(
// [{ left: 'title' }],
// json.title,
// "test",
// json
// )
// );

// chai.expect(json)
// .to.not.deep.equal(
// Sql.whereNotEquals(
// [{ left: 'template' }],
// json.title,
// "truc",
// json
// )
// );
// });

// /**
// * Sql.whereLike
// *
// */
// it('Sql.whereLike()', function() {
// var Sql = require('../src/cli').Sql;

// var json = {"template": "test", "title": "test"}

// chai.expect(json)
// .to.deep.equal(
// Sql.whereLike(
// [{ left: 'template' }],
// json.template,
// "te",
// json
// )
// );

// chai.expect(json)
// .to.not.deep.equal(
// Sql.whereLike(
// [{ left: 'title' }],
// json.title,
// "tu",
// json
// )
// );
// });
});

0 comments on commit dfccfe4

Please sign in to comment.