我在AngularJS中创建了enter 事件指令,因此我想为该指令运行测试用例。但我不知道如何为输入事件编写代码。
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();
});
})