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

Request: Syntactic sugar for combining calledOnce and calledWithExactly #1247

Closed
andys8 opened this issue Jan 21, 2017 · 4 comments
Closed
Labels

Comments

@andys8
Copy link

andys8 commented Jan 21, 2017

Hi guys, great library. I'd like to request a feature regarding spies. If using them, we most likely want to make sure that the spy is called exactly as expected by using calledWithExactly. We also want to make sure this happens only a single time by using calledOnce. Of course, this is possible right now. But I think it should be the default assertion (compared to partial matching) and therefore it would be great if boilerplate could be reduced by introducing a combined method like onceCalledWithExactly or calledOnceWithExactly. What do you think?

Example

Using sinon-chai, this ...

expect(mySpy).calledOnce.and.calledWithExactly(expectedValue);

could be replaced by this:

expect(mySpy).calledOnceWithExactly(expectedValue);
@andys8 andys8 changed the title Request: Syntactic sugar for combining calledOnce and calledWithExactly Request: Syntactic sugar for combining calledOnce and calledWithExactly Jan 21, 2017
@zipzapp
Copy link

zipzapp commented May 11, 2017

I'd like to second this request. Our team frequently uses both calledOnce and calledWithExactly and it would enforce best practices to consolidate them into one method.

@stale
Copy link

stale bot commented Jan 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 13, 2018
@stale stale bot closed this as completed Jan 20, 2018
@krzkaczor
Copy link
Contributor

It's super surprising for me that there is no such method. I actually thought that calledWithExactly asserts that there was just 1 call (so it's was really exactly called with this params and that's all). I am gonna work on this now.

@krzkaczor
Copy link
Contributor

FYI: it was just merged :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants