Skip to content

Commit

Permalink
Merge pull request #1533 from noisecapella/gs/fix_undefined
Browse files Browse the repository at this point in the history
resolvesThis should override previous throws
  • Loading branch information
fatso83 authored Aug 16, 2017
2 parents 28bcedc + f87b512 commit 4310343
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sinon/default-behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ module.exports = {
fake.reject = false;
fake.returnValueDefined = false;
fake.exception = undefined;
fake.exceptionCreator = undefined;
fake.fakeFn = undefined;
},

Expand Down
18 changes: 18 additions & 0 deletions test/stub-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,24 @@ describe("stub", function () {

assert.same(stub.resolvesThis(), stub);
});

it("overrides throws behavior for error objects", function () {
var instance = {};
instance.stub = createStub.create().throws(new Error()).resolvesThis();

return instance.stub().then(function (actual) {
assert.same(actual, instance);
});
});

it("overrides throws behavior for dynamically created errors", function () {
var instance = {};
instance.stub = createStub.create().throws().resolvesThis();

return instance.stub().then(function (actual) {
assert.same(actual, instance);
});
});
});

describe(".returnsArg", function () {
Expand Down

0 comments on commit 4310343

Please sign in to comment.