Closed tristanls closed 11 years ago
Sorry for the late reply.
This is quite usefull. But I'm quite not happy with the naming and the use of this. How about following syntax instead of this?
function hookme() {}
nodemock.mock('foo').takes('aa', 'bb', function() {}).calls(2, ["yes"]).hook(hookme);
This explains what we trying do. What do you think?
Hey,
From what I understand, you're proposing a name change from callhook
to hook
? Sure, that works. The order of the call is flexible already right? I think it works both ways, so that should work as well.
Cheers
Yes. That's true. You are correct.
On Mon, Apr 9, 2012 at 3:23 AM, tristanls < reply@reply.github.com
wrote:
Hey,
From what I understand, you're proposing a name change from
callhook
tohook
? Sure, that works. The order of the call is flexible already right? I think it works both ways, so that should work as well.Cheers
Reply to this email directly or view it on GitHub: https://github.com/arunoda/nodemock/pull/15#issuecomment-5018718
Arunoda Susiripala
@arunoda http://twitter.com/arunoda http://gplus.to/arunodahttps://github.com/arunoda http://www.linkedin.com/in/arunoda
I think the ctrl option already provides this? Or am I missing something?
No It's different. ctrl() can be used to trigger the callback at anytime within your code. default is, it will be called at the moment where the mocked method is called.
But hook() can be used to execute some code inside the mocked function.
I know this can be hook is not needed always and it's use cases can be implemented with some other design using the same set of functions. But having hook() is okay. there may have some use :)
I'm no longer supporting this pull request.
This is to enable executing code in testing environment after mock is triggered.
Http response use case:
Trigger assertion asynchronously use case: