lundi 2 février 2015

How To Find Elements By Id in Angular Directive Test

I have a directive that renders the following html in a unit test:



<div id="published-envs">
<strong>Published to</strong>
<!-- ngRepeat: env in fundConfigurationVersion.publicationEnvironments --><div data-ng-repeat="env in fundConfigurationVersion.publicationEnvironments" class="ng-binding ng-scope">
QA (Jan 29, 2015)
</div><!-- end ngRepeat: env in publicationEnvironments --><div data-ng-repeat="env in publicationEnvironments" class="ng-binding ng-scope">
PROD (Jan 30, 2015)
</div><!-- end ngRepeat: env in publicationEnvironments -->
</div>


I am trying to get a hold of the div#published-envs and assert that it has two child divs in it.


I have tried the following but it does not work: var environments = element.find('#published-envs'); //comes back empty


What is the correct way to find elements by id in an angular unit test?


Aucun commentaire:

Enregistrer un commentaire