Closed dominictarr closed 13 years ago
alright, I figured out a way to do this, but you have to make an empty mock function first.
var mock = nodemock.mock('ignore')
mock.mock('chaining').takes('whatever').returns(mock)
no ideal, but it's a feasible work around.
This is how it's work and :) you are correct,, you've found the correct way of doing that :) or you can try this too.
var mocked = nodemock.mock('foo').returns(nodemock.mock('bar'));`
great, that also inforces what order the chains should be called in, cheers!
Great to hear that you are using nodemock. Happy testing. :-)
If a method returns
this
you can chain it's function callsbut you can't go
mock = nodemock.mock('foo').returns(mock)
one way to support this would be to ab able to add more functions to a mock
mock = nodemock.mock('foo').returns(mock) nodemock.more(mock).mock('chain').returns(mock)
cheers. Dominic