33var chai = require ( 'chai' )
44 , sinon = require ( 'sinon' )
55 , expect = chai . expect
6+ , errors = require ( '../../lib/errors' )
67 , Support = require ( __dirname + '/support' )
78 , Sequelize = Support . Sequelize
89 , Promise = Sequelize . Promise ;
@@ -20,7 +21,10 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), function () {
2021 } ) ;
2122 it ( 'Sequelize Errors instances should be instances of Error' , function ( ) {
2223 var error = new Sequelize . Error ( ) ;
23- var validationError = new Sequelize . ValidationError ( ) ;
24+ var validationError = new Sequelize . ValidationError ( 'Validation Error' , [
25+ new errors . ValidationErrorItem ( '<field name> cannot be null' , 'notNull Violation' , '<field name>' , null )
26+ , new errors . ValidationErrorItem ( '<field name> cannot be an array or an object' , 'string violation' , '<field name>' , null )
27+ ] ) ;
2428
2529
2630 var sequelize = new Sequelize ( ) ;
@@ -34,6 +38,7 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), function () {
3438 expect ( validationError ) . to . be . instanceOf ( Sequelize . ValidationError ) ;
3539 expect ( validationError ) . to . be . instanceOf ( Error ) ;
3640 expect ( validationError ) . to . have . property ( 'name' , 'SequelizeValidationError' ) ;
41+ expect ( validationError . message ) . to . match ( / n o t N u l l V i o l a t i o n : < f i e l d n a m e > c a n n o t b e n u l l , \n s t r i n g v i o l a t i o n : < f i e l d n a m e > c a n n o t b e a n a r r a y o r a n o b j e c t / ) ;
3742
3843 expect ( instError ) . to . be . instanceOf ( Sequelize . Error ) ;
3944 expect ( instError ) . to . be . instanceOf ( Error ) ;
0 commit comments