【发布时间】:2016-08-31 12:53:08
【问题描述】:
控制器中的功能:
angular.module('myApp').controller('MyController', function(){
$scope.f = function($event){
$event.preventDefault();
//logic
return data;
}
})
describe('MyController', function(){
'use strict';
var MyController,
$scope;
beforeEach(module('myApp'));
beforeEach($inject(function($rootScope, $controller){
$scope = $rootScope.$new();
MyController = $controller('MyController', {
$scope: $scope
})
}));
})
it('should...', function(){
//fire event and expect data
})
$scope.f函数用在指令中,可以被ng-click="f($event)"执行
单元测试中火灾事件的正确方法是什么?
【问题讨论】:
-
您能提供更多上下文信息吗?
-
@EvanBechtol 对不起,我希望现在更清楚了
标签: angularjs unit-testing jasmine karma-jasmine