-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
Import nise #1461
Import nise #1461
Conversation
Added the
It's better that people only get this release through conscious upgrade, and not part of regular install (damn you loose versioning!!!!) |
FYI these changes should end up int he release notes. |
I have pushed new commits that imports the new nise module from npm. There are still some deprecations we can remove: Shall we remove them as part of this |
Remove, remove, remove! |
I think we can merge this and remove any remaining deprecations in another PR. Anyone opposed? |
Me! I am already working on removing the last deprecations, so I'd rather just keep this branch open for a bit longer, than either have |
OK, I think I have mopped up all the previously deprecated stuff. If we're going to put out a new |
I am attending a family event today, so won't be able to contribute anything until tonight at the earliest and perhaps not even until sometime next week. |
Ping @sinonjs/core do you have any further comments for this PR? |
Njet. All good. |
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.
A few small things like missing tests. But the biggest thign I see is missing documentation about what is being removed.
lib/sinon/collection.js
Outdated
if (arguments.length > 2) { | ||
return sandboxStub.apply(this, arguments); | ||
throw new TypeError("stub(obj, 'meth', fn) has been removed, see documentation"); |
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.
Remove the duplication. This will still get thrown on line 97 below.
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.
Indeed, well spotted
@@ -3,15 +3,13 @@ | |||
var valueToString = require("./util/core/value-to-string"); | |||
var hasOwnProperty = Object.prototype.hasOwnProperty; | |||
|
|||
function stubNonFunctionProperty(object, property, value) { | |||
function stubNonFunctionProperty(object, property) { |
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.
2 things:
- This should throw like the other stub method with too many arguments.
- The replacement for this usage is not documented (like
stub(...).callFake(fn)
).
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.
This should throw like the other stub method with too many arguments.
It is internal only, and is called inside sandbox.stub
, which does throw for too many arguments.
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.
The replacement for this usage is not documented
The practice of using sandbox.stub
for stubbing out properties has been documented for awhile, admittedly, not very well.
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.
I have pushed another commit to improve documentation for stubbing out non-function properties
var original = object[property]; | ||
|
||
if (!hasOwnProperty.call(object, property)) { | ||
throw new TypeError("Cannot stub non-existent own property " + valueToString(property)); | ||
} | ||
|
||
object[property] = 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.
Looks like most of the property tests were removed. I see negative tests, but no positive tests.
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.
Stubbing properties is the responsibility of collection.js
, it has several tests covering this.
@@ -2,7 +2,6 @@ | |||
|
|||
module.exports = { | |||
calledInOrder: require("./called-in-order"), | |||
configureLogError: require("./log_error"), |
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 this was accessible, we should document that it was removed even if it was previously deprecated.
@@ -49,20 +41,13 @@ exports.useFakeTimers = fakeTimers.useFakeTimers; | |||
exports.clock = fakeTimers.clock; | |||
exports.timers = fakeTimers.timers; | |||
|
|||
var event = require("./sinon/util/event"); | |||
exports.Event = deprecated.wrap(event.Event, deprecated.defaultMsg("Event")); |
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.
Documentation for all of these changes.
|
||
// This is deprecated and will be removed in a future version of sinon. | ||
// We will only consider pull requests that fix serious bugs in the implementation | ||
function stubDescriptor(object, property, descriptor) { |
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.
Documentation.
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.
This was an internal only file.
That sinon.stub
only accepts two arguments has been documented in this very commit
@@ -597,6 +597,7 @@ describe("sinonSandbox", function () { | |||
|
|||
it("allows stubbing setters", function () { | |||
var object = { | |||
foo: undefined, |
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.
Did this need to be added?
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.
It is necessary, otherwise we run into the input validation of collection.stub, that checks for own properties on stubbing targets.
TypeError: Cannot stub non-existent own property foo
@fearphage thank you for your thorough review. I think I have addressed all your comments. If you're satisfied, then I'll fold the review commit into the appropriate commit and merge it. |
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.
Are all the event deprecations and removals documented? It looks good for the most part besides my doc concerns.
I also noticed a bum test, but I unblocked the PR.
test/stub-test.js
Outdated
}}); | ||
|
||
assert.equals(obj.prop, 43); | ||
var stub = createStub(obj, "prop"); |
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.
This test has no assertions now. Add an assertion or remove the test.
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.
That was a mistake! I've fixed this in the offending commit and have rebased my branch
* sandbox.stub(obj, 'meth', val) * sinon.stub(obj, 'meth', fn) * sinon/util/core
`sinonStub` will take care of validating the length of the arguments
I think everything has been addressed. Since #1496 is also a |
This PR is part of #1453, it replaces fake xhr and fake server with
nise
To try it out
npm install
npm test