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

AssertWith doesn't behave properly when calling a function with the same arguments #45

xp500 opened this issue Feb 26, 2016 · 0 comments


Copy link

commented Feb 26, 2016

Asserting that a function has been called with a given parameter fails if that function was called with that parameter with an arity greater than one.

For example, the following assertions fail if the function sum is called with sum(1, 1).

expect(sum).to.have.been.called.with(1) (1)
expect(sum).to.have.been.called.with(1, 1) (2)

The reason is that the function assertWith counts all the occurrences of the parameters for each argument and then expects it to be equal to the length of the arguments.

Assertion (1) will fail because 1 appears twice in the arguments list, but the length of the with arguments is 1.

Assertion (2) will also fail because 1 appears twice in the arguments list, so for every with argument it is counted twice, so it's been found "4" times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.