Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Replace custom stubbing with sinon #30

Closed
wants to merge 1 commit into from
Closed

Replace custom stubbing with sinon #30

wants to merge 1 commit into from

Conversation

chadian
Copy link

@chadian chadian commented Aug 26, 2019

This solves two issues:

  1. Letting sinon do the heavy work of stubbing, tracking stubs, and handling any edge cases around stubbing.
  2. Fix an issue where getters have to be wrapped in an extra function.

On that second point we were running into an issue where if you are stubbing an object you had to know if the property was a getter or not, which is difficult when the thing is imported from a dependency, ie:

Both should be consistently stubbed via .stub(obj, 'prop', 'abc'):

const obj = {
  prop: 'abc';
}
const obj = {
  get prop() {
    return 'abc';
  }
}

Where currently, a regular object can be stubbed like .stub(obj, 'prop', 'abc') and a getter is stubbed like .stub(obj, 'prop', () => 'abc') (as seen in the tests).

Because this would change the way getters are stubbed this would be a breaking change for fancy-test where existing getter stubs would have to drop a function wrapper.

@salesforce-cla
Copy link

Thanks for the contribution! Before we can merge this, we need @chadian to sign the Salesforce.com Contributor License Agreement.

@RasPhilCo
Copy link
Contributor

Cleaning up - if you think this PR is still valid, reopen it. Thanks!

@RasPhilCo RasPhilCo closed this Dec 17, 2020
@mdonnalley mdonnalley mentioned this pull request Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants