mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
baseModel: delete properties instead of setting them to undefined, transform toJSON only not toObject
This commit is contained in:
@@ -39,7 +39,7 @@ describe('Base model plugin', () => {
|
||||
let sanitized = schema.statics.sanitize({ok: true, noUpdateForMe: true});
|
||||
|
||||
expect(sanitized).to.have.property('ok');
|
||||
expect(sanitized).to.have.property('noUpdateForMe');
|
||||
expect(sanitized).not.to.have.property('noUpdateForMe');
|
||||
expect(sanitized.noUpdateForMe).to.equal(undefined);
|
||||
});
|
||||
|
||||
@@ -48,12 +48,12 @@ describe('Base model plugin', () => {
|
||||
private: ['amPrivate']
|
||||
});
|
||||
|
||||
expect(schema.options.toObject.transform).to.exist;
|
||||
expect(schema.options.toJSON.transform).to.exist;
|
||||
let objToTransform = {ok: true, amPrivate: true};
|
||||
let privatized = schema.options.toObject.transform({}, objToTransform);
|
||||
let privatized = schema.options.toJSON.transform({}, objToTransform);
|
||||
|
||||
expect(objToTransform).to.have.property('ok');
|
||||
expect(objToTransform).to.have.property('amPrivate');
|
||||
expect(objToTransform).not.to.have.property('amPrivate');
|
||||
expect(objToTransform.amPrivate).to.equal(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user