From e0c75bd83a92e5e1f614f9d7504d5b303b26fc96 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Sun, 28 May 2017 18:40:48 +0200 Subject: [PATCH] Add test for #950, show that it has been fixed (#1435) See https://github.com/sinonjs/sinon/issues/950 --- test/issues/issues-test.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/issues/issues-test.js b/test/issues/issues-test.js index 6f451b4dc..89d92d239 100644 --- a/test/issues/issues-test.js +++ b/test/issues/issues-test.js @@ -122,6 +122,33 @@ describe("issues", function () { }); }); + describe("#950 - first execution of a spy as a method renames that spy", function () { + it("should not rename spies", function () { + var expectedName = "proxy"; + + function bob() {} + var spy = sinon.spy(bob); + + assert.equals(spy.name, expectedName); + + var obj = { methodName: spy }; + assert.equals(spy.name, expectedName); + + spy(); + assert.equals(spy.name, expectedName); + + obj.methodName.call(null); + assert.equals(spy.name, expectedName); + + obj.methodName(); + assert.equals(spy.name, expectedName); + + obj.otherProp = spy; + obj.otherProp(); + assert.equals(spy.name, expectedName); + }); + }); + describe("#1026", function () { it("should stub `watch` method on any Object", function () { // makes sure that Object.prototype.watch is set back to its old value