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

Commit 49fc1fbd by sdepold

dialect unspecific dao specs

1 parent 84887e7c
Showing with 54 additions and 0 deletions
if(typeof require === 'function') {
const buster = require("buster")
, Sequelize = require("../index")
, config = require("./config")
, dialects = ['sqlite', 'mysql', 'postgres']
}
buster.spec.expose()
dialects.forEach(function(dialect) {
describe('DAO@' + dialect, function() {
before(function(done) {
var self = this
this.sequelize = new Sequelize(config.database, config.username, config.password, {
logging: false
})
this.User = this.sequelize.define('User', {
username: { type: Sequelize.STRING },
touchedAt: { type: Sequelize.DATE, defaultValue: Sequelize.NOW }
})
self.sequelize
.getQueryInterface()
.dropAllTables()
.success(function() {
self.User
.sync({ force: true })
.success(done)
.error(function(err) {
console.log(err)
})
})
.error(function(err) { console.log(err) })
})
describe('default values', function() {
describe('current date', function() {
it('should store a date in touchedAt', function() {
var user = this.User.build({ username: 'a user'})
expect(user.touchedAt instanceof Date).toBeTrue()
})
it("should store the current date in touchedAt", function() {
this.useFakeTimers().tick(5000)
var user = this.User.build({ username: 'a user'})
expect(+user.touchedAt).toBe(5000)
})
})
})
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!