vendredi 1 juillet 2016

Mocking out angular.element in jasmine test

I have a controller that has a code snippet like this on controller initialization:

$scope.grid = angular.element('#MyGrid').kendoGrid(myData);

When I go to run jasmine tests, it dies before I can even get to my test code...the error I am getting is:

undefined is not a constructor (evaluating 'angular.element('#MyGrid').kendoGrid')

This makes sense because I obviously don't have the MyGrid element in the DOM. How can I mock out the angular.element call to return a mock object with the kendoGrid method?

Thanks!

Aucun commentaire:

Enregistrer un commentaire