Skip to content
Snippets Groups Projects
Commit e844e480 authored by vjrj's avatar vjrj
Browse files

Remove warnings with moch in tests

parent 1aeda977
No related branches found
No related tags found
No related merge requests found
...@@ -148,6 +148,7 @@ class _G1PayAmountFieldState extends State<G1PayAmountField> { ...@@ -148,6 +148,7 @@ class _G1PayAmountFieldState extends State<G1PayAmountField> {
TextPosition(offset: _controller.text.length)); TextPosition(offset: _controller.text.length));
value = _controller.text; value = _controller.text;
} }
return validateDecimal(sep: sep, locale: locale, amount: value); return validateDecimal(
sep: sep, locale: locale, amount: value, tr: (String s) => tr(s));
} }
} }
...@@ -10,6 +10,15 @@ void main() { ...@@ -10,6 +10,15 @@ void main() {
expect(parsedDouble, equals(1234.56)); expect(parsedDouble, equals(1234.56));
}); });
test(
'localizedParseToDouble parses a localized double zero ended string correctly',
() {
const String doubleString = '1.234,50';
final double parsedDouble =
parseToDoubleLocalized(locale: 'es', number: doubleString);
expect(parsedDouble, equals(1234.5));
});
test('valid and invalid comments', () { test('valid and invalid comments', () {
const List<String> invalidText = <String>['á', '`e', 'ç', 'ñ', ',']; const List<String> invalidText = <String>['á', '`e', 'ç', 'ñ', ','];
const List<String> validText = <String>[ const List<String> validText = <String>[
...@@ -29,59 +38,72 @@ void main() { ...@@ -29,59 +38,72 @@ void main() {
reason: 'Failed $text'); reason: 'Failed $text');
} }
}); });
String tr(String s) => s;
test('Valid decimal number - en_US', () { test('Valid decimal number - en_US', () {
final String? result = final String? result =
validateDecimal(sep: '.', locale: 'en_US', amount: '123.45'); validateDecimal(sep: '.', locale: 'en_US', amount: '123.45', tr: tr);
expect(result, null); expect(result, null);
}); });
test('Valid decimal number - es_ES', () { test('Valid decimal number - es_ES', () {
final String? result = final String? result =
validateDecimal(sep: ',', locale: 'es_ES', amount: '123,45'); validateDecimal(sep: ',', locale: 'es_ES', amount: '123,45', tr: tr);
expect(result, null); expect(result, null);
}); });
test('Empty amount - en_US', () { test('Empty amount - en_US', () {
final String? result = final String? result =
validateDecimal(sep: '.', locale: 'en_US', amount: ''); validateDecimal(sep: '.', locale: 'en_US', amount: '', tr: tr);
expect(result, null);
});
test('Amount starts with separator - es_ES', () {
final String? result =
validateDecimal(sep: ',', locale: 'es_ES', amount: ',45', tr: tr);
expect(result, null); expect(result, null);
}); });
test('Amount starts with separator - es_ES', () { test('Amount starts with separator - es_ES', () {
final String? result = final String? result =
validateDecimal(sep: ',', locale: 'es_ES', amount: ',45'); validateDecimal(sep: ',', locale: 'es_ES', amount: ',45', tr: tr);
expect(result, null);
});
test('Amount decimal ends with zero - es_ES', () {
final String? result =
validateDecimal(sep: ',', locale: 'es_ES', amount: '2,40', tr: tr);
expect(result, null); expect(result, null);
}); });
test('Negative number - en_US', () { test('Negative number - en_US', () {
final String? result = final String? result =
validateDecimal(sep: '.', locale: 'en_US', amount: '-123.45'); validateDecimal(sep: '.', locale: 'en_US', amount: '-123.45', tr: tr);
expect(result, 'enter_a_positive_number'); expect(result, 'enter_a_positive_number');
}); });
test('Invalid number - es_ES', () { test('Invalid number - es_ES', () {
final String? result = final String? result =
validateDecimal(sep: ',', locale: 'es_ES', amount: '12a,45'); validateDecimal(sep: ',', locale: 'es_ES', amount: '12a,45', tr: tr);
expect(result, 'enter_a_valid_number'); expect(result, 'enter_a_valid_number');
}); });
test('Invalid number - es_ES', () { test('Invalid number - es_ES', () {
final String? result = final String? result =
validateDecimal(sep: ',', locale: 'es_ES', amount: '0.45'); validateDecimal(sep: ',', locale: 'es_ES', amount: '0.45', tr: tr);
expect(result, 'enter_a_valid_number'); expect(result, 'enter_a_valid_number');
}); });
test('Invalid number - en', () { test('Invalid number - en', () {
final String? result = final String? result =
validateDecimal(sep: '.', locale: 'en', amount: '0,45'); validateDecimal(sep: '.', locale: 'en', amount: '0,45', tr: tr);
expect(result, 'enter_a_valid_number'); expect(result, 'enter_a_valid_number');
}); });
group('humanizeContact', () { group('humanizeContact', () {
test('Should return "your_wallet" if pubKey matches publicAddress', () { test('Should return "your_wallet" if pubKey matches publicAddress', () {
const String publicAddress = 'your_public_address'; const String publicAddress = 'your_public_address';
const Contact contact = Contact(pubKey: 'your_public_address'); const Contact contact = Contact(pubKey: 'your_public_address');
final String result = humanizeContact(publicAddress, contact); final String result = humanizeContact(publicAddress, contact, false, tr);
expect(result, 'your_wallet'); expect(result, 'your_wallet');
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment