我想在视图测试中测试可用选项,但我在md-select
中看不到所选的选项,我看到placeHolder
文字。
测试的错误消息如“Expected 'Country ' to be 'Turkey', 'selected country must be loaded correctly in view'.
”
视图:
<md-select [ngModelOptions]="{standalone: true}" placeholder="Country"
style="margin-top: 6px;"
[(ngModel)]="customer.address.country">
<md-option *ngFor="let country of countries"
[value]="country.code">
{{ country.name}}
</md-option>
</md-select>
试验:
it('customer should edit', fakeAsync(() => {
fixture.detectChanges();
tick();
let countryInput = fixture.debugElement.query(By.css("md-select[placeHolder='Country']"));
expect(countryInput.nativeElement.innerText).toBe("Turkey", "selected country must be loaded correctly in view");
}))