Skip to content

Commit

Permalink
Revert "Merge pull request sinonjs#1738 from nfriedly/issue-1736"
Browse files Browse the repository at this point in the history
This reverts commit cee8156, reversing
changes made to f2696bd.
  • Loading branch information
mroderick authored and Franck Romano committed Oct 1, 2019
1 parent 3629770 commit 07b5666
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
4 changes: 2 additions & 2 deletions lib/sinon/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
38 changes: 0 additions & 38 deletions test/issues/issues-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]);
});
});
});

0 comments on commit 07b5666

Please sign in to comment.