How do i check whether a particular function is defined or not?
I am using following unit test, doesn't work.
controller
$scope.filterData = function () {
$scope.currentPage = "1";
$scope.displayData($scope.currentPage);
......
}
test
var ctrl, scope;
beforeEach(function () {
// load the module
module('myApp');
// inject Controller for testing
inject(function ($rootScope, $controller) {
scope = $rootScope.$new();
ctrl = $controller('DataCtrl', { $scope: scope });
});
});
it('should have a filterData function to be defined', function () {
expect(scope.filterData()).toBeDefined();
});