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

Fix issue with local options being overwritten with Nexmo class #311

Merged
merged 1 commit into from
Jul 28, 2020

Conversation

kellyjandrews
Copy link
Contributor

@kellyjandrews kellyjandrews commented Jul 23, 2020

Fixes #295

@kellyjandrews kellyjandrews requested review from garann and conshus July 23, 2020 21:25
@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2020

Codecov Report

Merging #311 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #311   +/-   ##
=======================================
  Coverage   90.44%   90.44%           
=======================================
  Files          25       25           
  Lines         827      827           
=======================================
  Hits          748      748           
  Misses         79       79           
Impacted Files Coverage Δ
src/Nexmo.js 98.52% <100.00%> (ø)

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 58b361c...d26f251. Read the comment docs.

appendToUserAgent: "EXT",
debug: true
};
new Nexmo(

let passedOptions = Object.assign({}, localOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we Object.assign here? We should pass localOptions to the constructor then assert that they were not changed

Copy link
Contributor Author

@kellyjandrews kellyjandrews Jul 24, 2020

Choose a reason for hiding this comment

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

Because localOptions === localOptions regardless, and the test will always pass. I need to compare it to the original without the original changing.

Choose a reason for hiding this comment

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

Can you help me understand, also? From what I am reading this test tests the validity of Object.assign() but it's not testing it from within the constructor of the Nexmo object. Wouldn't we want our test to test this function call from within the constructor, specifically?

Choose a reason for hiding this comment

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

Ah, I see that you are actually testing both in this block. Okay, as long as the nexmo object's values are also tested, I'm good with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bencgreenberg It's an unfortunate side effect of javascript - you have to store the original as a separate object to validate if the two objects remain the same.

@kellyjandrews kellyjandrews added this to the v 2.9.0 milestone Jul 27, 2020
Copy link

@hummusonrails hummusonrails left a comment

Choose a reason for hiding this comment

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

I tested this locally, both with the spec and manually and it fixes the issue documented that it is meant to resolve. 🚀

@kellyjandrews kellyjandrews merged commit cd1c187 into master Jul 28, 2020
@kellyjandrews kellyjandrews deleted the constructor-options branch March 11, 2021 15:55
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.

Nexmo constructor changes of given options object
4 participants