title: Angular test - enable button when form becomes valid
body: <p>I have such a form in my App, with a required field, and a button that becomes enabled once the field is not empty.</p>
  <p>upload.component.html</p>
  <pre><code>&lt;form [formGroup]=&quot;uploadForm&quot; (ngSubmit)=&quot;Submit()&quot;&gt;
                      &lt;mat-form-field class=&quot;full-width&quot; appearance=&quot;outline&quot;&gt;
                        &lt;mat-label translate&gt;enter-name&lt;/mat-label&gt;
                        &lt;input matInput formControlName=&quot;name&quot;&gt;
                      &lt;/mat-form-field&gt;
  &lt;button mat-raised-button  [disabled]=&quot;!uploadForm.valid&quot;&gt;Send&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>And upload.component.ts:</p>
  <pre><code>  ngOnInit() {
      this.uploadForm = new FormGroup({
         'name': new FormControl('', Validators.required),
        );
     }
  </code></pre>
  <p>I want to test this case.</p>
  <p>Trying this, upload.component.spec.ts:</p>
  <pre><code>   it('should be ok', waitForAsync(() =&gt; {
                  let fixture = TestBed.createComponent(DashboardComponent);
                  fixture.detectChanges();
                  fixture.whenStable().then(() =&gt; {
                    let input = fixture.debugElement.nativeElement.querySelector('[matInput]');
                    input.value = 'someValue';
                    input.dispatchEvent(new Event('input'));
       expect(fixture.debugElement.nativeElement.querySelector('button').disabled).toBeFalsy();
                      });
          }));
  </code></pre>
  <p>Doesn't work.</p>
  <p>Can anyone please help me with the syntax?</p>
  <p>Thanks!</p>