When having an angular directive that inside its template has a button with ng-click attribute, should I test the effect of actual action taken (clicking) or of, an attached to ng-click attribute, function call?
In other words, for a directive, that has a template like this:
<div>
<button ng-click="game.start()">start</button>
</div>
should I test what clicking does or what game.start function does?
I am aware that later the function game.start can be changed for a different one. Also, ng-click can be removed and click event can be caught in a different way.
Unit testing with triggerHandler('click') is tempting but directive's template can also change. That would mean that I need some "proven" access to DOM nodes, namely through id attributes.
Should I attach id attributes on nodes just for unit testing sake or should I take a different aproach to the problem?
Aucun commentaire:
Enregistrer un commentaire