angularjs triggerHandler is not firing binded event in unit test


with angularJs 1.0.2 I created simple directive that binds to click event on element.

I tried to unittest it with testacular

var linked;
beforeEach(inject(function($rootScope, $compile) {
    scope = $rootScope.$new();
    var widget_definition = '<a href="path" my-directive="">click here</a>';
    linked = $compile(widget_definition);

it('chceck logic on click', function() {
    var button = linked(scope);
    // this doesnt work so I give up :/

but it tells me that there is no such function defined on button element. but this is already jQ(lite) object and in other tests I can use methods defined for jQlite.

is this a bug in angular??


triggerHandler was added in 1.0.3

Here’s a JSFiddle that doesn’t throw an exeception

btw, if you are dealing with UI changes you might want to do e2e tests.

Answered By – jaime

Answer Checked By – Robin (AngularFixing Admin)

Leave a Reply

Your email address will not be published.