I have a service that uses the findByIdAndUpdate (which uses findOneAndUpdate under the hood), which I need to test.
The problem is that as far as I can tell, the finderMock
function that I pass to the toReturn
method get called with just the query, which contains the id
but neither the options
nor the update
objects.
However, to properly test my service's method, I need access to those, since I need to check that the options are correct and that the request is actually trying to update what it should.
Looking at the query
object and query.getQuery()
, I don't see anyway to access those objects.
Is there any way to access them ? If not, is there any way to properly test the findAndUpdate type methods ?