Vote count:
0
I have a regular angular app with a directive. This directive contains an element with a ng-click="clickFunction()"
call. All works well when I click that element. I now need to write a test for this click, making sure that this function was actually run when the element was clicked - this is what I'm having trouble with.
Here's a jsfiddle to illustrate my issue: http://ift.tt/1toV3z1
The controller contains a function clickFunction()
which should be called on click. The unit test should imitate a click on the directive's element and thus trigger the call to that function.
The clickFunction
is mocked with sinonjs so that I can check whether it was called or not. That test fails, meaning there was no click.
What am I doing wrong here?
I've seen the answer to similar questions like Testing JavaScript Click Event with Sinon but I do not want to user full jQuery, and I believe I'm mocking (spying on) the correct function.
Properly trigger a click event on an AngularJS directive in Mocha test suite
Aucun commentaire:
Enregistrer un commentaire