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

Commit 6374785c by sdepold

moved jasmine tests to spec-jasmine

1 parent 38135327
Showing with 29 additions and 98 deletions
...@@ -19,12 +19,13 @@ ...@@ -19,12 +19,13 @@
}, },
"devDependencies": { "devDependencies": {
"jasmine-node": "1.0.x", "jasmine-node": "1.0.x",
"sqlite3": ">=2.0.0" "sqlite3": ">=2.0.0",
"buster": "0.4.x"
}, },
"keywords": ["mysql", "orm", "nodejs", "object relational mapper"], "keywords": ["mysql", "orm", "nodejs", "object relational mapper"],
"main": "index", "main": "index",
"scripts": { "scripts": {
"test": "./node_modules/.bin/jasmine-node spec/" "test": "./node_modules/.bin/jasmine-node spec-jasmine/"
}, },
"bin": { "bin": {
"sequelize": "bin/sequelize" "sequelize": "bin/sequelize"
......
// var config = require("./config/config")
// , Sequelize = require("../index")
// , User = null
// , sequelize = new Sequelize(config.database, config.username, config.password, {
// logging: false,
// dialect: dialect
// })
// , Helpers = new (require("./config/helpers"))(sequelize)
// describe('DAO', function() {
// var setup = function() {
// Helpers.async(function(done) {
// User = sequelize.define('User', { username: Sequelize.STRING })
// User.sync({ force: true }).success(done)
// })
// }
// beforeEach(function() { Helpers.dropAllTables(); setup() })
// afterEach(function() { Helpers.dropAllTables() })
// describe('findAll', function() {
// it("can handle dates correctly", function() {
// })
// })
// })
module.exports = {
username: "root",
password: null,
database: 'sequelize_test',
host: '127.0.0.1',
rand: function() {
return parseInt(Math.random() * 999)
}
}
var Factories = module.exports = function(helpers) {
this.helpers = helpers
this.sequelize = this.helpers.sequelize
}
Factories.prototype.DAO = function(daoName, options, callback, count) {
count = count || 1
var self = this
, daos = []
this.helpers.async(function(done) {
var DAO = self.sequelize.daoFactoryManager.getDAO(daoName)
var create = function(cb) {
DAO.create(options).on('success', function(dao) {
daos.push(dao)
cb && cb()
}).on('failure', function(err) {
console.log(err)
done()
})
}
var cb = function() {
if(--count) {
create(cb)
} else {
done()
callback && callback(daos)
}
}
create(cb)
})
}
Factories.prototype.User = function(options, callback, count) {
this.DAO('User', options, callback, count)
}
Sequelize = require("../../index")
var Helpers = module.exports = function(sequelize) {
this.sequelize = sequelize
this.Factories = new (require("./factories"))(this)
}
Helpers.prototype.sync = function() {
var self = this
this.async(function(done) {
self.sequelize
.sync({force: true})
.success(done)
.failure(function(err) { console.log(err) })
})
}
Helpers.prototype.drop = function() {
var self = this
this.async(function(done) {
self.sequelize
.drop()
.on('success', done)
.on('failure', function(err) { console.log(err) })
})
}
Helpers.prototype.dropAllTables = function() {
var self = this
this.async(function(done) {
self.sequelize
.getQueryInterface()
.dropAllTables()
.success(done)
.error(function(err) { console.log(err) })
})
}
Helpers.prototype.async = function(fct) {
var done = false
runs(function() {
fct(function() { return done = true })
})
waitsFor(function(){ return done })
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!