-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): add test for amount input validation
- Loading branch information
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:my_wit_wallet/widgets/validations/vtt_amount_input.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() async { | ||
test('Decimal number has more than 9 digits', () async { | ||
String amount = '0.00000000001'; | ||
VttAmountInput _amount = VttAmountInput.dirty( | ||
value: amount, availableNanoWit: 1000, allowValidation: true); | ||
|
||
expect(_amount.validator(amount, avoidWeightedAmountCheck: true), | ||
errorMap[AmountInputError.decimals]); | ||
}); | ||
test('Not enough Funds', () async { | ||
String amount = '0.000000001'; | ||
VttAmountInput _amount = VttAmountInput.dirty( | ||
value: amount, availableNanoWit: 0, allowValidation: true); | ||
|
||
expect(_amount.validator(amount, avoidWeightedAmountCheck: true), | ||
errorMap[AmountInputError.notEnough]); | ||
}); | ||
test('Amount cannot be zero', () async { | ||
String amount = '0'; | ||
VttAmountInput _amount = VttAmountInput.dirty( | ||
value: amount, availableNanoWit: 0, allowValidation: true); | ||
|
||
expect(_amount.validator(amount, avoidWeightedAmountCheck: true), | ||
errorMap[AmountInputError.zero]); | ||
}); | ||
test('Amount can be zero', () async { | ||
String amount = '0'; | ||
VttAmountInput _amount = VttAmountInput.dirty( | ||
value: amount, | ||
availableNanoWit: 0, | ||
allowValidation: true, | ||
allowZero: true); | ||
|
||
expect(_amount.validator(amount, avoidWeightedAmountCheck: true), null); | ||
}); | ||
test('Invalid amount', () async { | ||
String amount = '0.'; | ||
VttAmountInput _amount = VttAmountInput.dirty( | ||
value: amount, | ||
availableNanoWit: 0, | ||
allowValidation: true, | ||
allowZero: true); | ||
|
||
expect(_amount.validator(amount, avoidWeightedAmountCheck: true), | ||
errorMap[AmountInputError.invalid]); | ||
}); | ||
} |