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

Commit 6a831c54 by Sascha Depold

added test for enum validation

1 parent ea1b5dbb
Showing with 21 additions and 0 deletions
......@@ -446,5 +446,26 @@ describe(Support.getTestDialectTeaser("DaoValidator"), function() {
expect(successfulFoo.validate()).to.be.null
done()
})
it('validates enums', function() {
var values = ['value1', 'value2']
var Bar = this.sequelize.define('Bar' + config.rand(), {
field: {
type: Sequelize.ENUM,
values: values,
validate: {
isIn: [values]
}
}
})
var failingBar = Bar.build({ field: 'value3' })
, errors = failingBar.validate()
expect(errors).not.to.be.null
expect(errors.field).to.have.length(1)
expect(errors.field[0]).to.equal("Unexpected value or invalid argument: field")
})
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!