Skip to content

Commit

Permalink
Merge pull request #1779 from BladeRunnerJS/ensure-test-method-invoca…
Browse files Browse the repository at this point in the history
…tion-returns

ensure functions wrapped by the invocation counter still return
  • Loading branch information
thecapdan authored Apr 12, 2017
2 parents 8455a4a + aef7def commit 5914a79
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ KnockoutInvocationCountPlugin.prototype.update = function(eElement, fValueAccess
KnockoutInvocationCountPlugin.prototype._getInvocationCountingProxyMethod = function(fOrigMethod) {
var fMethod = function() {
fOrigMethod.invocationCount++;
fOrigMethod.apply(this, arguments);
return fOrigMethod.apply(this, arguments);
};
fOrigMethod.invocationCount = 0;
return fMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ PresentationModelFixture.InvocationCountSetter.prototype._getInvocationCountingP
var fOrigMethod = this._getMethod();
var fMethod = function() {
fMethod.invocationCount++;
fOrigMethod.apply(this, arguments);
return fOrigMethod.apply(this, arguments);
};
fMethod.invocationCount = nInitialValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,23 @@
});
};

PresentationModelFixtureTest.prototype.test_wrappedFunctionsStillReturn = function()
{
var oPresentationModelFixture = new PresentationModelFixture();
var oPresentationModel = new PresentationModel();
oPresentationModelFixture.setComponent({getPresentationModel:function(){return oPresentationModel;}});

oPresentationModel.theFunction = function() {
return "a value";
};

oPresentationModelFixture.doGiven("theFunction.invocationCount", 0);

var valueHolder = oPresentationModel.theFunction();

assertEquals(valueHolder, "a value");
};

PresentationModelFixtureTest.prototype.test_invocationCountCanBeSetToANonZeroValue = function()
{
var oPresentationModelFixture = new PresentationModelFixture();
Expand Down

0 comments on commit 5914a79

Please sign in to comment.