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

Make sinon.stub() mock implementation when nothing is returned (& other tweaks) #291

Merged
merged 1 commit into from
Jun 9, 2022
Merged

Make sinon.stub() mock implementation when nothing is returned (& other tweaks) #291

merged 1 commit into from
Jun 9, 2022

Conversation

danbeam
Copy link
Contributor

@danbeam danbeam commented Jun 8, 2022

cc @lencioni @catc

In some recent PRs I noticed that sinon.stub(a, b) is transformed into jest.spyOn(a, b).mockClear() but it also needs a .mockImplementation() in the general case (when there's not a .return() or .returnArg()). So I've added that.

Additionally, I read sinon's doc on stub() and spy() and we don't need/implement stub(a) (which mocks all keys in the object) so I'm marking that as unsupported (it's not advised even from sinon's doc).

I added a warning when there's more than 3 arguments (which doesn't seem to be valid, AFAICT).

I also changed jest.fn().mockImplementation(...) to just jest.fn(...) because it's equivalent and shorter.

@codecov
Copy link

codecov bot commented Jun 8, 2022

Codecov Report

Merging #291 (43f869a) into main (93d99e0) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #291      +/-   ##
==========================================
+ Coverage   92.18%   92.22%   +0.04%     
==========================================
  Files          26       26              
  Lines        1842     1852      +10     
  Branches      381      385       +4     
==========================================
+ Hits         1698     1708      +10     
  Misses        102      102              
  Partials       42       42              
Impacted Files Coverage Δ
src/transformers/sinon.ts 87.31% <100.00%> (+0.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 93d99e0...43f869a. Read the comment docs.

@skovhus
Copy link
Owner

skovhus commented Jun 9, 2022

This is awesome! Thanks for fixing this. 👏

@skovhus skovhus merged commit 287b1e3 into skovhus:main Jun 9, 2022
This was referenced Jun 29, 2022
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.

2 participants