How to unit testing an $destroy event of a Directive in angularjs?
I have the code in my directive:
scope.$on(\'$destroy\', function () { //clean som
You can select the DOM from the template of your directive and get the scope of it, then run $destroy().
Ex:
your tpl:
""
your test:
it('test on destroy', function(){ var isolateScope = $(element).find('#tuna').eq(0).scope(); isolateScope.$destroy(); })
Hope help you!