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 test for #1796, failing to stub Array.prototype.sort #1876

Merged
merged 3 commits into from
Aug 9, 2018

Conversation

mroderick
Copy link
Member

This PR shows that the issue described in #1796 has been fixed (in c2c7814)

Once this is merged, we should create a new release.

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. npm test

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

@mroderick mroderick added the semver:patch changes will cause a new patch version label Aug 6, 2018
@coveralls
Copy link

coveralls commented Aug 6, 2018

Pull Request Test Coverage Report for Build 2625

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 95.324%

Totals Coverage Status
Change from base Build 2616: -0.05%
Covered Lines: 2029
Relevant Lines: 2083

💛 - Coveralls

describe("#1796 - cannot stub Array.prototype.sort", function () {
it("it should not fail with RangeError", function () {
var stub = sinon.stub(Array.prototype, "sort");
[1, 2, 3].sort();
Copy link
Member

Choose a reason for hiding this comment

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

All tests should have assertions. Assert that this doesn't throw.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I've added an extra commit. Once happy with this PR, I'll fold the commits together


describe("#1796 - cannot stub Array.prototype.sort", function () {
it("it should not fail with RangeError", function () {
var stub = sinon.stub(Array.prototype, "sort");
Copy link
Member

@fearphage fearphage Aug 8, 2018

Choose a reason for hiding this comment

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

Does this stub need to .callThrough() (like the linked issue) to trigger the RangeError?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, .callThrough() is not necessary to trigger the RangeError.

it("it should not fail with RangeError", function () {
refute.exception(function () {
var stub = sinon.stub(Array.prototype, "sort");
[1, 2, 3].sort();
Copy link
Member

Choose a reason for hiding this comment

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

This should be the only line that we are concerned with not throwing an exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, I've pushed a commit that fixes that

@mroderick mroderick merged commit 6d56bbf into sinonjs:master Aug 9, 2018
@mroderick mroderick deleted the document-issue-1796.js branch August 9, 2018 17:46
@mroderick
Copy link
Member Author

Dang, I merged without squashing ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch changes will cause a new patch version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants