Skip to content

Commit

Permalink
Fix #1770: Reset history on sandbox reset
Browse files Browse the repository at this point in the history
  • Loading branch information
mroderick committed May 1, 2018
1 parent 7d1eff1 commit 6b47a83
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/sinon/sandbox.js
Expand Up @@ -92,6 +92,7 @@ function Sandbox() {

sandbox.reset = function reset() {
applyOnEach(collection, "reset");
applyOnEach(collection, "resetHistory");
};

sandbox.resetBehavior = function resetBehavior() {
Expand Down
20 changes: 18 additions & 2 deletions test/sandbox-test.js
Expand Up @@ -735,8 +735,14 @@ describe("Sandbox", function () {
var sandbox = this.sandbox = createSandbox();
var fakes = sandbox.getFakes();

fakes.push({reset: sinonSpy()});
fakes.push({reset: sinonSpy()});
fakes.push({
reset: sinonSpy(),
resetHistory: sinonSpy()
});
fakes.push({
reset: sinonSpy(),
resetHistory: sinonSpy()
});
});

it("calls reset on all fakes", function () {
Expand All @@ -748,6 +754,16 @@ describe("Sandbox", function () {
assert(fake0.reset.called);
assert(fake1.reset.called);
});

it("calls resetHistory on all fakes", function () {
var fake0 = this.sandbox.getFakes()[0];
var fake1 = this.sandbox.getFakes()[1];

this.sandbox.reset();

assert(fake0.resetHistory.called);
assert(fake1.resetHistory.called);
});
});

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

0 comments on commit 6b47a83

Please sign in to comment.