-
-
Notifications
You must be signed in to change notification settings - Fork 772
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 usingPromise() method on fakes to fix issue #2293 #2301
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tackling this! Just a few quibbles on the implementations. Not seeing why you want to handle the native and the injected implementation as two different things, so you could simplify it.
lib/sinon/fake.js
Outdated
throw new TypeError("Expected f argument to be a Function"); | ||
} | ||
function fakeClass() { | ||
var promiseLib; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they always have the same interface, why bother with branching?
var promiseLib; | |
var promiseLib = Promise; |
lib/sinon/fake.js
Outdated
if (promiseLib) { | ||
return promiseLib.resolve(value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (promiseLib) { | |
return promiseLib.resolve(value); | |
} |
lib/sinon/fake.js
Outdated
if (promiseLib) { | ||
return promiseLib.reject(value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (promiseLib) { | |
return promiseLib.reject(value); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fatso83,
That actually makes a whole lot of sense, will take those edits. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also noticed that i'm not wrapping the the rejected object as an Error. Will correct that as well.
…required code branching
This is great, thanks a lot, @romanbalayan! |
Hi @fatso83, I'm also currently participating in the hacktoberfest event organized by Digital Ocean, hopefully it would not be much of a bother for you to add the hacktoberfest-accepted label to this PR so it may be counted towards my progress? Thank you! |
Done! |
Great PR! Thank you @romanbalayan |
This has been published with |
Add usingPromise() method on fakes
Fix issue #2293. Added implementation of usingPromise() to be able to override global Promise library.
How to verify - mandatory
npm install
Checklist for author
npm run lint
passes