Skip to content

Commit 28bcedc

Browse files
authored
Merge pull request #1530 from noisecapella/gs/regression_onfirstcall
Fix regression for issue #1526 regarding onFirstCall().throws()
2 parents 350717d + 7b53434 commit 28bcedc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/sinon/behavior.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ var proto = {
115115
isPresent: function isPresent() {
116116
return (typeof this.callArgAt === "number" ||
117117
this.exception ||
118+
this.exceptionCreator ||
118119
typeof this.returnArgAt === "number" ||
119120
this.returnThis ||
120121
this.resolveThis ||

test/stub-test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ describe("stub", function () {
137137
stub();
138138
});
139139
});
140+
141+
it("throws only on the first call", function () {
142+
var stub = createStub.create();
143+
stub.returns("no exception");
144+
stub.onFirstCall().throws();
145+
146+
assert.exception(function () {
147+
stub();
148+
});
149+
150+
// on the second call there is no exception
151+
assert.same(stub(), "no exception");
152+
});
140153
});
141154

142155
describe(".resolves", function () {

0 commit comments

Comments
 (0)