From ff14f3b2d0df7d78a71b7bd66b47e47d90cd59cc Mon Sep 17 00:00:00 2001 From: George Schneeloch Date: Mon, 14 Aug 2017 10:01:20 -0400 Subject: [PATCH] Fix regression for issue #1526 regarding onFirstCall().throws() --- lib/sinon/behavior.js | 1 + test/stub-test.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/sinon/behavior.js b/lib/sinon/behavior.js index 042b5ec20..3684dd9a7 100644 --- a/lib/sinon/behavior.js +++ b/lib/sinon/behavior.js @@ -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 || diff --git a/test/stub-test.js b/test/stub-test.js index f6ba2c856..40cbddb4e 100644 --- a/test/stub-test.js +++ b/test/stub-test.js @@ -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 () {