mercredi 6 avril 2016

Javascript NaN preventing from running angular unit tests

I am attempting to test a directive but when I mock out the directive a line in the middle of the directive runs an error. Which prevents my tests from running

$scope.getIterations = function (its) {
        return new Array(its);
    };

Returns

 RangeError: Invalid array length

Which makes sense as the argument its returns NaN.

I figured that I could call var its = [1,2,3]; $scope.getIterations(its)

Inside of a beforeEach but that did not make any difference as the error code returns the same thing.

Maybe I am misunderstanding this code, but I am not sure how to get around this for the unit tests.

Aucun commentaire:

Enregistrer un commentaire