Skip to content

Conversation

@mgabeler-lee-6rs
Copy link
Contributor

Purpose

Fix #1964 by adding a helper method to walk the stub parent links to find the wrappedMethod value for the callsThrough behavior.

Background

If you try to use the callsThrough behavior on a withArgs stub, calling the stub with the matching args will fail, because the behavior fails to locate the original wrapped method to call through to.

This is effectively a followup to #1442 / #1549.

Solution - optional

A simple helper method walks up stub.parent links until it finds a stub that has a wrappedMethod member.

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. npm test, or just npm run test-node, or just npm run test-node --grep 1964 to run the issue-specific test case

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.
    • N/A -- no standard library functions used

@coveralls
Copy link

coveralls commented Apr 30, 2019

Pull Request Test Coverage Report for Build 2859

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 94.186%

Files with Coverage Reduction New Missed Lines %
sinon/behavior.js 5 95.92%
Totals Coverage Status
Change from base Build 2857: -0.02%
Covered Lines: 1660
Relevant Lines: 1729

💛 - Coveralls

Copy link
Contributor

@fatso83 fatso83 left a comment

Choose a reason for hiding this comment

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

Very nice and readable test. Thank you! I just have one comment that I think should be addressed, with regards to the Fail Fast principle.

(code review)

Co-Authored-By: mgabeler-lee-6rs <[email protected]>
@fatso83 fatso83 merged commit 8559150 into sinonjs:master May 24, 2019
@fatso83
Copy link
Contributor

fatso83 commented May 24, 2019

Thanks!

@mgabeler-lee-6rs mgabeler-lee-6rs deleted the issue-1964 branch May 24, 2019 01:54
franck-romano pushed a commit to franck-romano/sinon that referenced this pull request Oct 1, 2019
* fix: add test case demonstrating sinonjs#1964

* fix: walk stub parent links to find wrappedMethod (fixes sinonjs#1964)

* fix: throw explicit error if wrapped method is missing
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.

callThrough doesn't work on a withArgs sub-stub

3 participants