Skip to content

Commit

Permalink
Fix regression for issue sinonjs#1526 regarding onFirstCall().throws()
Browse files Browse the repository at this point in the history
  • Loading branch information
George Schneeloch authored and Franck Romano committed Oct 1, 2019
1 parent 22ce032 commit ff14f3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sinon/behavior.js
Expand Up @@ -115,6 +115,7 @@ var proto = {
isPresent: function isPresent() {
return (typeof this.callArgAt === "number" ||
this.exception ||
this.exceptionCreator ||
typeof this.returnArgAt === "number" ||
this.returnThis ||
this.resolveThis ||
Expand Down
13 changes: 13 additions & 0 deletions test/stub-test.js
Expand Up @@ -137,6 +137,19 @@ describe("stub", function () {
stub();
});
});

it("throws only on the first call", function () {
var stub = createStub.create();
stub.returns("no exception");
stub.onFirstCall().throws();

assert.exception(function () {
stub();
});

// on the second call there is no exception
assert.same(stub(), "no exception");
});
});

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

0 comments on commit ff14f3b

Please sign in to comment.