test: undefined property values are preserved
This commit is contained in:
parent
9769df2c91
commit
7a7fcb2e34
|
@ -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');
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Reference in New Issue