有以下代码:
$scope.removePoint = function(point) {
$modal.open({
templateUrl: 'templates/deleting_modal.html',
controller: 'DeletingPointModalController',
size: 'sm',
resolve: {
points: function() {
return $scope.points;
},
point: function() {
return point;
}
}
});
};
我想测试一下:
describe('HomeController', function() {
beforeEach(module('app'));
var $scope;
beforeEach(inject(function(_$controller_, _$rootScope_){
$scope = _$rootScope_.$new();
_$controller_('HomeController', { $scope: $scope });
}));
});
但我不明白如何测试模态窗口是否已打开。预先感谢!
答案 0 :(得分:0)
您可以测试是否已调用方法open:
describe('$scope.removePoint', function() {
it('should call $modal.open', function() {
spyOn($modal, 'open');
$scope.removePoint();
expect($modal.open).toHaveBeenCalled();
});
});