Skip to content

Commit

Permalink
sinon.resetHistory() does not reset history (#2022)
Browse files Browse the repository at this point in the history
* removed the createStubInstance method fonr sinon.js
* added test
  • Loading branch information
rpgeeganage authored and fatso83 committed May 21, 2019
1 parent 2c708fe commit ff505fc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/sinon.js
Expand Up @@ -17,7 +17,6 @@ var apiMethods = {
spyCall: require("./sinon/call"),

expectation: require("./sinon/mock-expectation"),
createStubInstance: require("./sinon/stub").createStubInstance,
defaultConfig: require("./sinon/util/core/default-config"),

setFormatter: format.setFormatter,
Expand Down
38 changes: 38 additions & 0 deletions test/issues/issues-test.js
Expand Up @@ -599,4 +599,42 @@ describe("issues", function() {
assert.equals(fake.lastArg, false);
});
});

describe("#2016", function() {
function Foo() {
return;
}
Foo.prototype.testMethod = function() {
return;
};

var sandbox;
beforeEach(function() {
sandbox = sinon.createStubInstance(Foo);
});

afterEach(function() {
sinon.restore();
});

describe("called on individual stub method", function() {
it("should clear 'called' status on stub", function() {
sandbox.testMethod();
assert.isTrue(sandbox.testMethod.called);

sandbox.testMethod.resetHistory();
assert.isFalse(sandbox.testMethod.called);
});
});

describe("called on module", function() {
it("should clear 'called' status on all stubs", function() {
sandbox.testMethod();
assert.isTrue(sandbox.testMethod.called);

sinon.resetHistory();
assert.isFalse(sandbox.testMethod.called);
});
});
});
});

0 comments on commit ff505fc

Please sign in to comment.