3
我在AngularJS中有包含模块$文档的指令。
$document.click(function (e) {});
我一直尝试编写单元测试使用噶,它打破了测试,因为功能click()
不存在$document
,也尽量用$document
像keyup()
等功能,并得到了同样的问题:
TypeError: undefined is not a function
这是测试代码,这使得它失败:
describe('Directive: multiSelectMenu', function() {
var element, scope;
beforeEach(module('myApp'));
describe('Test setup', function() {
it ('Injecting required data', inject(function ($compile, $rootScope) {
scope = $rootScope.$new();
element = $compile(angular.element('<div multi-select-menu></div>'))(scope);
$rootScope.$apply();
scope = element.isolateScope();
scope.$apply();
}));
});
});
为什么它辉L·
但事件当我在Angular之前加载jQuery,在Karma上它看起来像$文件没有任何方法来空。 – 2014-11-26 08:49:08