Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling both callbacks passed to function #460

Closed
horaklukas opened this issue Apr 16, 2014 · 3 comments
Closed

Calling both callbacks passed to function #460

horaklukas opened this issue Apr 16, 2014 · 3 comments

Comments

@horaklukas
Copy link

When I have stubed function that takes two or more callback arguments, eg. drag(moveCallback, startCallback, stopCallback) then I need to invoke more than one callback at test. For example I want to invoke startCallback(x, y) for saving drag start position and then moveCallback(dx, dy) for setting image position (move it) with function img.position(x, y). But when I write test like this

img.drag.callsArgOn(1, img)
img.drag.callsArgOnWith(0, img, 20, 30)

setImageDragging(img)

Img.stream.position.should.been.calledWithExactly(20, 30)

only the second callback (at position 1) is called. Is there possibility to invoke both callbacks (with stub's method that changes context of callback)?

@mantoni
Copy link
Member

mantoni commented Apr 16, 2014

No, nothing that I know of.
But you can always invoke them yourself:

setImageDragging(img)

img.drag.callArgOn(1, img)
img.drag.callArgOnWith(0, img, 20, 20)

@horaklukas
Copy link
Author

That's exactly what I need, but I didnt find that method in actual documenation (http://sinonjs.org/docs/). Now i tried to search it in sources (v1.7.3) and it is really there. Many thanks and could it be added to docs?

@mantoni
Copy link
Member

mantoni commented May 22, 2017

The docs are still missing. This will be tracked by #1411. Closing.

@mantoni mantoni closed this as completed May 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants