这是我的js文件代码
$scope.close = function () {
modalInstance.close();
};
unit test case for the js code
beforeEach(inject(function($rootScope) {
var modalInstance = { close: function() {}, dismiss: function() {} };
$controller('BusinessRuleEditCtrl',
{
$scope: scope,
dataFactory: mockdataFactory,
$modal: modal,
modalInstance:modalInstance
});
}));
it(' scope.close () functionality is checked ', function () {
scope.close();
spyOn(modalInstance, 'close').toHaveBeenCalled();
});
当我尝试运行此规范时,我收到错误“无法读取属性'关闭'未定义”。任何建议都将受到赞赏....提前感谢。