我在下面进行了以下测试,其中我更新一个文本字段,然后进行API调用,然后,根据API响应,我希望另一个文本字段具有相同的值。但是,它始终失败,并显示错误'-------------------------------------
Function Do999(ByVal ThreeDigits) As String
'-------------------------------------
'Spells numbers from 001 to 999 to Words
'Mohsen Alyafei 17 Oct 2018
'Modified to add "and" by Mohsen Alyfei 07 July 2019
'On Entry: ThreeDigits 3 digit number 001 to 999
'On Exit : String of number in English words
'-----------------------------------------
Dim Ones(), Tens(), Separator As String, h As String, t As String, N1 As Integer, N2 As Integer, annd As String
Ones = Array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen")
Tens = Array("", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety")
ThreeDigits = Right("000" & ThreeDigits, 3) 'Align to 3 digits
annd = " " 'added to add "and"
If Right(ThreeDigits, 1) <> "0" Then Separator = "-"
N1 = Left(ThreeDigits, 1): N2 = Right(ThreeDigits, 2)
If N2 > 19 Then t = Tens(Val(Mid(ThreeDigits, 2, 1))) & Separator & Ones(Val(Right(ThreeDigits, 1))) Else t = Ones(N2)
If N1 > 0 Then
h = Ones(N1) & " Hundred"
If N2 > 0 Then annd = " and " 'added to add "and"
End If
Do999 = Trim(h & annd & t) 'var "annd" is normally a space
End Function
,根据API的响应,我期望结果为2 = 2。知道我该如何解决吗?
这里的堆叠闪电战:https://stackblitz.com/edit/http-get-post-dgcuur
测试
Expected '0' to equal '2'.
查看
it('should successfuly convert A to A', fakeAsync(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {
let fromAmountValueEl = fixture.debugElement.query(By.css('#fromAmountValue')).nativeElement;
expect(fromAmountValueEl.value).toEqual('0');
let toAmountValueEl = fixture.debugElement.query(By.css('#toAmountValue')).nativeElement;
expect(toAmountValueEl.value).toEqual('0');
fromAmountValueEl.value = '2'
fromAmountValueEl.dispatchEvent(new Event('input'));
fromAmountValueEl.dispatchEvent(new KeyboardEvent('keyup', {
'key': 'Enter'
}));
tick();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(fromAmountValueEl.value).toEqual('2');
expect(toAmountValueEl.value).toEqual('2');
});
});
}));
控制器
<input class="form-control form-control-lg" type="number" placeholder="0" [(ngModel)]="fromAmount"
(keyup)="updateRates()" id="fromAmountValue">
<select class="form-control form-control-lg" id="fromCurrency">
<option value="GBP">GBP</option>
</select>
<input class="form-control form-control-lg" type="number" placeholder="0" [(ngModel)]="toAmount"
(keyup)="updateRates()" id="toAmountValue">
<select class="form-control form-control-lg" [(ngModel)]="toCurrency" id="toCurrency">
<option value="GBP">GBP</option>
</select>