I have a template driven form with many inputs like
<input type="text" name="data" [(ngModel)]="data" [disabled]="disabled" />
I want to write a test that ensures that all inputs are disabled if the variable is disabledset to true. Below is my test for now. It works, but there are a few "disabled" properties on elementand element.nativeElementthat remain false. In addition, the displayed view in Chrome when stopped in the debugger does not appear to be disabled. In fact, only the "ng-reflect-is-disabled" attribute is true.
it("should disable all inputs when disabled is true", () => {
component.disabled = true;
fixture.detectChanges();
inputs = fixture.debugElement.queryAll(By.css('input'));
inputs.forEach(element => {
expect(element.attributes["ng-reflect-is-disabled"]).toBe('true');
});
});
Is there a better way by which I can check the status of a disconnected input?
source
share