mardi 2 mai 2017

How to Click a md-checkbox in jasmine test

template:

<md-checkbox id="myCheckBox" ng-model="isChecked"></md-checkbox>

test:

const el = compile(angular.element(html))(scope)[0];
$rootScope.$apply();
element = $(el);
element.find("#myCheckBox").click();
$rootScope.$apply();
expect(element.find("#myCheckBox").hasClass("md-checked")).toBe(true);

Through debugging I am certain that I am finding myCheckBox using jQuery and calling click on it. However after calling $rootScope.$apply the checkbox element is not checked. In fact it remains pristine and untouched. What am I missing?




Aucun commentaire:

Enregistrer un commentaire