test: undefined property values are preserved

This commit is contained in:
Miroslav Bajtoš 2015-02-04 09:08:28 +01:00
parent 9769df2c91
commit 7a7fcb2e34
2 changed files with 49 additions and 0 deletions

View File

@ -1,4 +1,5 @@
require('./datatype.test.js'); require('./datatype.test.js');
require('./basic-querying.test.js'); require('./basic-querying.test.js');
require('./manipulation.test.js');
require('./hooks.test.js'); require('./hooks.test.js');
require('./relations.test.js'); require('./relations.test.js');

View File

@ -192,6 +192,29 @@ describe('manipulation', function () {
done(); 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 () { 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 () { describe('destroy', function () {