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

Add calledOnceWith and calledOnceWithExactly #117

Merged
merged 1 commit into from
May 23, 2018
Merged

Add calledOnceWith and calledOnceWithExactly #117

merged 1 commit into from
May 23, 2018

Conversation

hexpunk
Copy link
Contributor

@hexpunk hexpunk commented Mar 3, 2018

This should resolve #116.

sinonMethod("calledWithExactly", "been called with exact arguments %*", "%D");
sinonMethod("calledOnceWithExactly", "been called exactly once with exact arguments %*", "%C");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, here's the thing about these, specifically their nonNegatedSuffixes. There's really no good way to address these new ones.

Using the ", but it was called %c%C" suffix doesn't make sense when it's only been called once. And using "%D" causes some odd formatting issues in the case of multiple calls.

With "%D", it ends up looking like this:

     AssertionError: expected spy to have been called with exact arguments A, BCall 1:
C A
A B
Call 2:
C A
B

I'm about 99.999% sure this is a sinon formatter issue and not an issue with sinon-chai.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be resolved by this ticket: sinonjs/sinon#1717

I'm still open to suggestions on how these nonNegatedSuffixes should be.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just using "%D" should work pretty well, after that Sinon bug is fixed at least. Do you agree?

package.json Outdated
"chai": "^4.1.0",
"eslint": "^3.19.0",
"chai": "^4.1.2",
"eslint": "^4.18.2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave dev dependency updates for a separate PR, and only update Sinon in this PR.

Copy link
Collaborator

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a few messages tests too?

@domenic
Copy link
Collaborator

domenic commented Mar 6, 2018

LGTM, but can you regenerate package-lock.json? I don't think you rolled back the changes there.

@hexpunk
Copy link
Contributor Author

hexpunk commented Mar 6, 2018

Good call. I did it all via Github.

@hexpunk
Copy link
Contributor Author

hexpunk commented Mar 6, 2018

What do you mean by "messages tests"? As in testing the formatting of the failure messages?

@domenic
Copy link
Collaborator

domenic commented Mar 6, 2018

Yeah, see messages.js. Historically we've had a lot of regressions there (e.g. via Sinon upgrades that make our current messages nonsensical) that those tests have caught.

@hexpunk
Copy link
Contributor Author

hexpunk commented Mar 6, 2018

I'll take a crack at that in the next couple of days when I get time. Thanks for reviewing this.

@hexpunk
Copy link
Contributor Author

hexpunk commented Mar 12, 2018

@domenic Just added some messages tests. Can you please take another look?

@domenic domenic merged commit 9fa3b07 into chaijs:master May 23, 2018
@domenic
Copy link
Collaborator

domenic commented May 23, 2018

Sorry for the massive delay here :(. This will go out in a release today!

@hexpunk hexpunk deleted the feature/116 branch May 24, 2018 02:49
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

Successfully merging this pull request may close these issues.

Support calledOnceWithExactly and calledOnceWith
2 participants