不要怂,就是干,撸起袖子干!

Commit 905f7a55 by sdepold

refactored specs

1 parent 5d7f96eb
Showing with 38 additions and 20 deletions
var config = require("./config/config") var config = require("./config/config")
, Sequelize = require("../index") , Sequelize = require("../index")
, sequelize = new Sequelize(config.database, config.username, config.password, { logging: false }) , sequelize = new Sequelize(config.database, config.username, config.password, { logging: false })
, Helpers = new (require("./config/helpers"))(sequelize) , Helpers = new (require("./config/helpers"))(sequelize)
, QueryGenerator = require("../lib/connectors/mysql/query-generator") , QueryGenerator = require("../lib/connectors/mysql/query-generator")
, util = require("util")
describe('QueryGenerator', function() { describe('QueryGenerator', function() {
beforeEach(function() { Helpers.sync() }) beforeEach(function() { Helpers.sync() })
afterEach(function() { Helpers.drop() }) afterEach(function() { Helpers.drop() })
describe('hashToWhereConditions', function() { var suites = {
it("should correctly transform array into IN", function() { 'hashToWhereConditions': [
expect( {
QueryGenerator.hashToWhereConditions({ id: [1,2,3] }) arguments: [{ id: [1,2,3] }],
).toEqual( expectation: "`id` IN (1,2,3)"
"`id` IN (1,2,3)" }
) ],
}) 'selectQuery': [
}) {
arguments: ['foo', { attributes: [['count(*)', 'count']] }],
expectation: 'SELECT count(*) as `count` FROM `foo`;'
}
]
}
describe('selectQuery', function() { Sequelize.Utils._.each(suites, function(tests, suiteTitle) {
it("should correctly convert arrays into aliases", function() { describe(suiteTitle, function() {
expect( tests.forEach(function(test) {
QueryGenerator.selectQuery('foo', { attributes: [['count(*)', 'count']] }) var title = 'correctly returns ' + test.expectation + ' for ' + test.arguments
).toEqual( it(title, function() {
'SELECT count(*) as `count` FROM `foo`;' var conditions = QueryGenerator[suiteTitle].apply(null, test.arguments)
) expect(conditions).toEqual(test.expectation)
})
})
}) })
}) })
// //describe('addIndexQuery', function() {
// // it("only returns the basics if only necessary parameters are passed", function() {
// // expect(
// // QueryGenerator.addIndexQuery('User', ['username', 'isAdmin'])
// // ).toEqual(
// // 'CREATE INDEX user_username_is_admin ON User username, isAdmin'
// // )
// // })
// //})
}) })
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!