Skip to content

Commit

Permalink
ensure functions wrapped by the invocation counter still return
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo committed Apr 11, 2017
1 parent 8455a4a commit aef7def
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 aef7def

Please sign in to comment.