From d872444e7215d225abb0c3f3452d11cf5eee49f3 Mon Sep 17 00:00:00 2001 From: Ruwan Pradeep Geeganage Date: Tue, 21 May 2019 12:59:50 +0200 Subject: [PATCH] sinon.resetHistory() does not reset history (#2022) * removed the createStubInstance method fonr sinon.js * added test --- lib/sinon.js | 1 - test/issues/issues-test.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/sinon.js b/lib/sinon.js index ad6a9f4a0..7fce809a0 100644 --- a/lib/sinon.js +++ b/lib/sinon.js @@ -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, diff --git a/test/issues/issues-test.js b/test/issues/issues-test.js index eda6a566a..9722298c0 100644 --- a/test/issues/issues-test.js +++ b/test/issues/issues-test.js @@ -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); + }); + }); + }); });