I'd like to test some document transformation which is executed in a Mongoose pre save hook. Simplified example:
mySchema.pre('save', function(callback) {
this.property = this.property + '_modified';
callback();
});
Test:
var testDoc = new MyDocument({ property: 'foo' });
// TODO -- how to execute the hook?
expect(testDoc.property).to.eql('foo_modified');
How can I manually execute this hook?
Aucun commentaire:
Enregistrer un commentaire