From 7a7fcb2e3486929678b4c4a05997dd999cda1ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 4 Feb 2015 09:08:28 +0100 Subject: [PATCH] test: undefined property values are preserved --- test/common.batch.js | 1 + test/manipulation.test.js | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/test/common.batch.js b/test/common.batch.js index a9aa1764..808ca6cb 100644 --- a/test/common.batch.js +++ b/test/common.batch.js @@ -1,4 +1,5 @@ require('./datatype.test.js'); require('./basic-querying.test.js'); +require('./manipulation.test.js'); require('./hooks.test.js'); require('./relations.test.js'); diff --git a/test/manipulation.test.js b/test/manipulation.test.js index d3e2b050..fac9698a 100644 --- a/test/manipulation.test.js +++ b/test/manipulation.test.js @@ -192,6 +192,29 @@ describe('manipulation', function () { done(); }); }); + + it('should preserve properties with "undefined" value', function(done) { + Person.create( + { name: 'a-name', gender: undefined }, + function(err, created) { + if (err) return done(err); + created.toObject().should.have.properties({ + id: created.id, + name: 'a-name', + gender: undefined + }); + + Person.findById(created.id, function(err, found) { + if (err) return done(err); + found.toObject().should.have.properties({ + id: created.id, + name: 'a-name', + gender: undefined + }); + done(); + }); + }); + }); }); describe('save', function () { @@ -349,6 +372,31 @@ describe('manipulation', function () { }); }); }); + + it('should preserve properties with "undefined" value', function(done) { + Person.create( + { name: 'a-name', gender: undefined }, + function(err, instance) { + if (err) return done(err); + instance.toObject().should.have.properties({ + id: instance.id, + name: 'a-name', + gender: undefined + }); + + Person.updateOrCreate( + { id: instance.id, name: 'updated name' }, + function(err, updated) { + if (err) return done(err); + updated.toObject().should.have.properties({ + id: instance.id, + name: 'updated name', + gender: undefined + }); + done(); + }); + }); + }); }); describe('destroy', function () {