vendredi 18 août 2017

Angular checkbox input disabled attribute

Inside of one the component of my angular (4) application, I have a template with an checkbox input in it, with the disabled attribute bind to a variable :

<input type="checkbox" name="test" [disabled]="disabled">

This input has the behavior we wouls expect : if the "disabled" variable is true, the checkbox is disabled and the oppposite.

But, when I try to test this behavior, I always get the disabled attribute of my input to false. So this test is always false (checkbox() sending my checkbox):

expect(checkbox().disabled).toBeTruthy();

The only way I can check is to verify the attribute "ng-reflect-is-disabled". Like this :

expect(checkbox().getAttribute('ng-reflect-is-disabled').toBeTruthy();

It works, but I find it quite ugly.

I wonder if this is a normal behavior when the disabled attribute is managed by angular ? Thank you !




Aucun commentaire:

Enregistrer un commentaire