unit testing again...
Posted: 20 Jan 2013, 00:03
So, I'm finally getting round to finishing the unit testing for my Util API, and I've run in to a stumbling block -- maybe someone with more experience of unit testing can help?
I've got a function like this, within the API's sandbox:
That adds an immutable 'difficultyScale()' function to the global object (docs).
I can easily test different parameter combinations, but I can't test them in relation to different 'difficultyIndex' values.
Any ideas on how to accomplish that?
I've got a function like this, within the API's sandbox:
Code: Select all
var difficultyIndex = Math.max( 0, ([EASY, MEDIUM, HARD, INSANE]).indexOf(difficulty) );
_global.addConst(
"difficultyScale",
function(/* easy, medium, hard, insane */) {
return arguments[ Math.min( arguments.length-1, difficultyIndex ) ];
}
);
I can easily test different parameter combinations, but I can't test them in relation to different 'difficultyIndex' values.
Any ideas on how to accomplish that?