From 94c5c1854143729549058fe27fd02962a1622348 Mon Sep 17 00:00:00 2001 From: Supasate Choochaisri Date: Wed, 13 Jul 2016 19:14:28 +0700 Subject: [PATCH] Add test to catch invalid date property Signed-off-by: Supasate Choochaisri --- test/datatype.test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/datatype.test.js b/test/datatype.test.js index b2e2f9dd..353d3857 100644 --- a/test/datatype.test.js +++ b/test/datatype.test.js @@ -52,6 +52,17 @@ describe('datatypes', function() { done(); }); + it('throws an error when property of type Date is set to an invalid value', + function() { + var myModel = db.define('myModel', { + date: { type: Date }, + }); + + (function() { + myModel.create({ date: 'invalid' }); + }).should.throw({ message: 'Invalid date: invalid' }); + }); + it('should keep types when get read data from db', function(done) { var d = new Date, id;