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
Calling sandbox.replace not cleaning up if called more than once #1779
Comments
Trying to replace a fake with a fake seems like something that should warrant an investigation by the programmer. I would prefer to have tests fail, rather than sinon glossing over my mistakes. Throwing get's my vote. |
I agree. I was trying to think of other scenarios, like using replace to set a number or so, but in any case, doing that multiple times in a single test seems dodgy. I’m also leaning more towards throwing now. |
When values where replaced multiple times, `restore` didn't restore the original value. This change causes `sandbox.replace` to throw if the given object / property combination was already used. Fixes #1779
When values where replaced multiple times, `restore` didn't restore the original value. This change causes `sandbox.replace` to throw if the given object / property combination was already used. Fixes #1779
This was fixed with |
When values where replaced multiple times, `restore` didn't restore the original value. This change causes `sandbox.replace` to throw if the given object / property combination was already used. Fixes sinonjs#1779
When calling
sandbox.replace
twice for the sameobject
+property
, the original state can not be restored.Reproduce:
There are two different ways to solve this:
sinon.replace
, likesinon.stub(obj, prop)
fails if it's already a fakesinon.replace
, but restore to the original state properlyI'd try to come up with an implementation if we know which direction to take. I'm not really decided here.
The text was updated successfully, but these errors were encountered: