angularjs - Link function is not triggered from Jasmine -
i trying test simple directive changes format of date , act filter input type:
module.exports = function () { return { require: 'ngmodel', link: function(scope, element, attrs, ngmodelcontroller) { ngmodelcontroller.$formatters.push(function(data) { if(data != null){ return data.gethours() + ":" + data.getminutes(); } }); } }; }; however link function not triggered jasmine test:
describe('formattimedirective', function () { var scope, element, compile, html; beforeeach(function(){ html = '<input type="text" format-time ng-model="duration" id="duration"/>'; inject(function($compile, $rootscope){ scope = $rootscope.$new(); scope.duration = new date(new date().sethours(0,0,0,0)); element = angular.element(html); compile = $compile(element); compile(scope); scope.$digest(); }) }); it('should format input value hh:mm', function(){ element.trigger('input'); scope.$digest(); expect(element.val()).toequal('00:00'); }); }); what missing?
Comments
Post a Comment