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

Copy all property descriptors to installed methods #349

Merged
merged 1 commit into from
May 28, 2021

Conversation

kevinoid
Copy link
Contributor

Purpose (TL;DR) - mandatory

Fix #347 by copying symbol own-properties to installed methods.

Background (Problem in detail) - optional

The for...in loop used to copy properties only copies string own-properties to installed methods, which omits util.promisify.custom necessary for util.promisify support on Node as added in #292.

Solution - optional

This PR copies all own-property descriptors to get both Symbol own-properties and to copy any getters/setters that may be added in the future.

If there's a reason getters/setters should not be copied, let me know and I can add an Object.assign polyfill to sinonjs/commons and use that instead.

Thanks for considering,
Kevin

Fixes: #347

The for...in loop would copy only string own-properties to installed
methods, which would omit util.promisify.custom necessary for
util.promisify support on Node as added in sinonjs#292.  Instead, copy all
own-property descriptors to get both Symbol own-properties and to copy
any getters/setters that may be added in the future.

Add tests for util.promisify behavior.

Fixes: sinonjs#347

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
@codecov
Copy link

codecov bot commented Jan 12, 2021

Codecov Report

Merging #349 (d7b3e11) into master (bdf8984) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #349      +/-   ##
==========================================
- Coverage   93.15%   93.12%   -0.03%     
==========================================
  Files           1        1              
  Lines         555      553       -2     
==========================================
- Hits          517      515       -2     
  Misses         38       38              
Flag Coverage Δ
unit 93.12% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/fake-timers-src.js 93.12% <100.00%> (-0.03%) ⬇️

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 bdf8984...d7b3e11. Read the comment docs.

@fatso83 fatso83 merged commit ac7e84c into sinonjs:master May 28, 2021
@fatso83
Copy link
Contributor

fatso83 commented May 28, 2021

I don't know why this has been dormant for five months, but I see @benjamingr approved it, so I guess it's good. Just merge it the next time, Benjamin, unless there's something specific you want a second pair of eyes on (in which case you just ping that someone) 🙂

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.

Support util.promisify on installed functions
3 participants