我正在表单字段的弹出窗口中加载数据。当我运行它时,输入区域填充有正确的字符串,但是当我尝试对其进行测试时-它为空''。测试期间未使用服务。
HTML
<p>
Receiver currency Xpath:
<mat-form-field appearance="outline" class="fields">
<input #toCurrencyXpath name="toCurrencyXpath"
(blur)="update(toCurrencyXpath.value)"
type="text"
matInput
[(ngModel)]="data.toCurrencyXpath">
</mat-form-field>
</p>
TyepScript
bank = {
name: 'Nordea',country: 'DK',pageurl: 'http://n.dk',buyxpath: 'abc',sellxpath: 'abc',fromCurrency: 'abc',toCurrencyXpath: 'abc',unit: 'M100',id: 'abc',};
it('should get receiver currency Xpath',() => {
const detComponent = new BankDetailsComponent(service,bank,fb,dialog);
fixture.whenStable();
fixture.detectChanges();
console.log(detComponent.name); //reads the value of the class variable
const currency: HTMLElement = fixture.debugElement.query(By.css('#toCurrencyXpath')).nativeElement;
fixture.whenStable();
fixture.detectChanges();
expect(currency.textContent).toBe('abc'); //Expected '' to be 'abc'.
});