javascript - How to mock a click in jasmine/karma -
i struggling mock out click check prevent.default.
in directive got this.
mycustomthing.addeventlistener('click', event => { event.preventdefault(); });
then in test m trying test so.
it('prevents default on click', function () { mycustomthing.addeventlistener = jasmine.createspy('addeventlistener'); mycustomthing.click(); expect(mycustomthing.addeventlistener) .tohavebeencalled(); });
when test following error: expected spy addeventlistener have been called. appreciated. thank in advance.
Comments
Post a Comment