1

New to unit testing mat-form-field which has an input, which gets it from a form and mat-error which has error messsage. Have to enter an invalid input to verify the error message.

<div class="px-3">

    <mat-form-field class="formField">

        <mat-label>threshold</mat-label>

        <input matInput placeholder="Threshold" formControlName="threshold" 
               required type="number" min="0" max="1" step="0.0001"
               (blur)="onValueChange($event.target)" id="rebalanceThreshold" />

        <percent-change-label class="mat-input-element" id="percentLabel"
                [inputValue]="holdingForm.rebalanceThreshold.value">
        </percent-change-label>

        <mat-error class='errorMessage' id="rebalanceThresholdError" 
                *ngIf="holdingForm.rebalanceThreshold.errors">
            {{ testForm.getValidationError('threshold') }}
        </mat-error>

    </mat-form-field>
</div>
Anna
  • 2,988
  • 3
  • 15
  • 29

0 Answers0