Add test to catch invalid date property

Signed-off-by: Supasate Choochaisri <supasate.c@gmail.com>
See https://github.com/strongloop/loopback-datasource-juggler/pull/1000
This commit is contained in:
Supasate Choochaisri 2016-07-13 19:14:28 +07:00 committed by Simon Ho
parent 4e5ae72eef
commit f1a70094fa
1 changed files with 11 additions and 0 deletions

View File

@ -51,6 +51,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;