Skip to content

Commit

Permalink
implemented stub#resetHistory method - fixes #863
Browse files Browse the repository at this point in the history
* refactored stub#reset to call .resetHistory() and .resetBehvaior()
  • Loading branch information
fearphage committed Oct 3, 2015
1 parent 324475a commit 5d9b118
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/sinon/stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@
}
},

resetHistory: sinon.spy.reset,

reset: function () {
sinon.spy.reset.call(this);
this.resetHistory();
this.resetBehavior();
},

Expand Down
13 changes: 13 additions & 0 deletions test/stub-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,19 @@
}
},

".resetHistory": {
"resets history": function () {
var stub = sinon.stub();

stub(1);
stub.reset();
stub(2);

assert(stub.calledOnce);
assert.equals(stub.getCall(0).args[0], 2);
}
},

".resetBehavior": {
"clears yields* and callsArg* sequence": function () {
var stub = sinon.stub().yields(1);
Expand Down

0 comments on commit 5d9b118

Please sign in to comment.