I have a simple component that consists of a toggle and some other elements:
<mat-slide-toggle (change)="toggle($event)" [checked]="false" attX="test"> ... </mat-slide-toggle>
<p> ... </p>
For testing, I would like to be able to know from the DOM whether the toggle is switched on or off. To do this, I created the nativeElement and use it for my tests. Everything works as expected however I'm not sure how to get the value of my toggle (true/false) using the toggleButtonElement variable.
let toggleButtonElement = fixture.nativeElement.querySelector('my-container').querySelector('mat-slide-toggle') as HTMLElement;
toggleElement.getAttribute('attX') //returns 'test' :)
toggleElement.getAttribute('checked') //returns null :(
I'm pretty new to Angular/Jasmine so forgive me if I'm missing something obvious.