【发布时间】:2014-09-15 16:45:23
【问题描述】:
我在 AngularJS 中创建了 enter event 指令,所以我想为该指令运行测试用例。但我不知道如何为输入事件编写代码。
describe('Unit Test: Enter Event', function() {
var elm, compile, scope;
beforeEach(function() {
module('att.sandbox.attEnterEvent');
inject(function($compile, $rootScope) {
compile = $compile;
scope = $rootScope.$new();
});
});
/*scenarion 1*/
it("Enetr Key should call the method inside controller", function() {
elm = angular.element('<input type="text" att-enter-event="enterEvent()">');
elm = compile(elm)(scope);
scope.$digest();
scope.enterEvent = jasmine.createSpy();
//**Here i want to add enter event test case**
expect().toHaveBeenCalled();
});
})
【问题讨论】:
-
你的意思是输入关键事件是吗?
-
是的..我想为enter evet写测试用例
-
我真的不明白你的实际查询是什么
-
@Sprottenwels 我想为输入事件编写 jasmine 测试用例。
-
你在写单元测试还是e2e测试?
标签: javascript angularjs unit-testing jasmine angular-directive