angularjs - Angular-Mock override parent directive and mock it -


i trying mock directive resides on same module of it's parent. since want isolate test child directive trying mock parent. feasible if both resided on different modules since on same multiple directives same name. bypass tried put on mock directive:

        return {                 priority: 100,                 terminal:true,                 restrict:'ce',                 scope:{                     zoom:'@'                 },                 template:'<div ng-transclude></div>',                 controlleras:'parentcontroller',                 controller:mockcontroller,                 transclude: true             }; 

the problem while can override parent directive doing so, child directive never called since has lower priority , terminal halt execution.

what in search of way override directive definition while testing on karma-jasmine , using angular.mock.

when add directive automatically creates factory , put directive on array multiple directives can respond same markup.

this person got way of making working creating service name of directive.unfortunately due angular changes solution didn't solved me yet because angular demanding $$bindings key on directive , $$modulename, adding factory solved .

i got mock this:

    angular.mock.module('themoduleiwanttotest');     angular.mock.module(function($provide){         $provide.factory('mockparentdirective', function(){                 var directive={                     priority:0,                     name:'mockparent',                     restrict:'ce',                     scope:{                         zoom:'@'                     },                     template:'<div ng-transclude></div>',                     controlleras:'mockparentcontroller',                     controller:mockcontroller,                     transclude: true,                     $$modulename:'themoduleiwanttotest',                     $$bindings:{}                 };                 return [directive];             }         );      }); 

in mockparent declared directive want override.

i don't think best way way found override directive on angular 1.4.2


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -