From ba05b5a3d5b745e6c4213f7ec95935690ab5ec43 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Fri, 30 Mar 2018 14:39:00 +0200 Subject: [PATCH] Revert "Merge pull request #1738 from nfriedly/issue-1736" This reverts commit cee81561f967ea6b1f29c844c58e76182a0eb93c, reversing changes made to f2696bd149309011b0f8167b76868e30c650bf58. --- lib/sinon/behavior.js | 4 ++-- test/issues/issues-test.js | 38 -------------------------------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/lib/sinon/behavior.js b/lib/sinon/behavior.js index acf08fad6..03faba8a6 100644 --- a/lib/sinon/behavior.js +++ b/lib/sinon/behavior.js @@ -101,7 +101,7 @@ function callCallback(behavior, args) { var proto = { create: function create(stub) { - var behavior = extend(stub.bind(), proto); + var behavior = extend({}, proto); delete behavior.create; delete behavior.addBehavior; delete behavior.createBehavior; @@ -219,7 +219,7 @@ function createBehavior(behaviorMethod) { function addBehavior(stub, name, fn) { proto[name] = function () { fn.apply(this, [this].concat([].slice.call(arguments))); - return this; + return this.stub || this; }; stub[name] = createBehavior(name); diff --git a/test/issues/issues-test.js b/test/issues/issues-test.js index 7827252ed..4d8cd25c2 100644 --- a/test/issues/issues-test.js +++ b/test/issues/issues-test.js @@ -420,42 +420,4 @@ describe("issues", function () { refute.isTrue(spyProp.get.called); }); }); - - describe("#1736 - onCall + yield + returns", function () { - it("should return the correct value without onCall", function () { - var stub = sinon.stub().yields("yield val").returns("return val"); - var cb = sinon.spy(); - - var ret = stub(cb); - - assert.equals(ret, "return val"); - assert.equals(cb.args, [["yield val"]]); - }); - it("should return the correct value with onCall", function () { - var stub = sinon.stub().onCall(0).yields("yield val").returns("return val"); - var cb = sinon.spy(); - - var ret = stub(cb); - - assert.equals(ret, "return val"); - assert.equals(cb.args, [["yield val"]]); - }); - it("should return the correct value with multiple onCalls", function () { - var stub = sinon.stub() - .onCall(0).yields("yield val").returns("return val") - .onCall(1).yields("second yield val").returns("second return val"); - var cb = sinon.spy(); - var cb2 = sinon.spy(); - - var ret = stub(cb); - var ret2 = stub(cb2); - - - assert.equals(ret, "return val"); - assert.equals(cb.args, [["yield val"]]); - - assert.equals(ret2, "second return val"); - assert.equals(cb2.args, [["second yield val"]]); - }); - }); });