0
如何檢查某個特定函數是否被定義?Angularjs單元測試 - 要定義的功能
我正在使用以下單元測試,不起作用。
控制器
$scope.filterData = function() {
$scope.currentPage = "1";
$scope.displayData($scope.currentPage);
......
}
測試
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();
});