Monitor Mongoose save transaction with Sinon.js

I would like to write a test that verifies that a specific property will be stored using Mongoose, for example:

var newUser = new userModel({
    id: /*something*/,
    gu: true
});

newUser.save(function (err, user) {
    /* ... */
    res.send(user.id);
});

      

In my tests, I want to make sure the property is gu

set to true. I can stub out easily save()

, however I cannot verify what is gu

set to true as it save()

is a function of the object and therefore not part of the parameters. Any ideas?

+3


source to share





All Articles