I made a static method for one a my models and I woudlike to mock it with sinon.
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var schema = new Schema({
name: String
});
schema.static('addName', function (name_id, name) {
...
});
module.exports = mongoose.model('Name', schema);
and
addNameSpy = sinon.spy(Name, "addName");
But it doesn't seem to work: the method is called, but addNameSpy.called
is still false
. Any idea to mock a mongoose static method ?
Thanks.
Aucun commentaire:
Enregistrer un commentaire