-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(expect): fix sinon-chai style API #9943
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ export const ChaiStyleAssertions: ChaiPlugin = (chai, utils) => { | |
| name: keyof Assertion, | ||
| delegateTo: keyof Assertion, | ||
| ) { | ||
| utils.addChainableMethod( | ||
| utils.addMethod( | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Chai's Not sure what was the purpose but ours aren't chainable anyways, so just switched to |
||
| chai.Assertion.prototype, | ||
| name, | ||
| function (this: Chai.AssertionStatic & Assertion, ...args: any[]) { | ||
|
|
@@ -56,13 +56,13 @@ export const ChaiStyleAssertions: ChaiPlugin = (chai, utils) => { | |
| } | ||
| return jestMethod.call(this, ...args) | ||
| }, | ||
| () => {}, | ||
| ) | ||
| } | ||
|
|
||
| // API to (somewhat) mirror sinon-chai | ||
| // https://github.com/chaijs/sinon-chai | ||
| defProperty('called', 'toHaveBeenCalled') | ||
| defProperty('calledOnce', 'toHaveBeenCalledOnce') | ||
| defProperty('returned', 'toHaveReturned') | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| defPropertyWithArgs('calledTwice', 'toHaveBeenCalledTimes', 2) | ||
| defPropertyWithArgs('calledThrice', 'toHaveBeenCalledTimes', 3) | ||
|
|
||
|
|
@@ -71,10 +71,14 @@ export const ChaiStyleAssertions: ChaiPlugin = (chai, utils) => { | |
| defMethod('calledOnceWith', 'toHaveBeenCalledExactlyOnceWith') | ||
| defMethod('lastCalledWith', 'toHaveBeenLastCalledWith') | ||
| defMethod('nthCalledWith', 'toHaveBeenNthCalledWith') | ||
| defMethod('returned', 'toHaveReturned') | ||
| defMethod('returnedWith', 'toHaveReturnedWith') | ||
| defMethod('returnedTimes', 'toHaveReturnedTimes') | ||
| defMethod('lastReturnedWith', 'toHaveLastReturnedWith') | ||
| defMethod('nthReturnedWith', 'toHaveNthReturnedWith') | ||
| defMethod('calledBefore', 'toHaveBeenCalledBefore') | ||
| defMethod('calledAfter', 'toHaveBeenCalledAfter') | ||
|
|
||
| // TODO: implement | ||
| // defMethod('thrown', 'toHaveThrown') | ||
|
Comment on lines
+82
to
+83
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we'd implement but just noted that they aren't fully ported yet. |
||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this was oversight or hallucination. Probably no way back to remove
returnedWith, so nowreturnedWithandreturnedare essentially same.