Skip to content

Commit

Permalink
refactor(test): add group for formats
Browse files Browse the repository at this point in the history
  • Loading branch information
mockturtl committed Sep 23, 2023
1 parent b4dcbd9 commit 29a0724
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions test/flutter_libphonenumber_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,33 @@ void main() {
});

group('getPhoneMask', () {
test('with removeCountryCodeFromMask=false', () async {
final res = const CountryWithPhoneCode.us().getPhoneMask(
format: PhoneNumberFormat.international,
type: PhoneNumberType.mobile,
removeCountryCodeFromMask: false,
);
late CountryWithPhoneCode subj;
late PhoneNumberFormat fmt;
group('intl format', () {
setUp(() {
subj = CountryWithPhoneCode.us();
fmt = PhoneNumberFormat.international;
});

expect(
res,
'+0 000-000-0000',
reason: 'mask should contain country code in it',
);
});
test('with removeCountryCodeFromMask=false', () async {
final res = subj.getPhoneMask(
format: fmt,
type: PhoneNumberType.mobile,
removeCountryCodeFromMask: false);

test('with removeCountryCodeFromMask=true', () async {
final res = const CountryWithPhoneCode.us().getPhoneMask(
format: PhoneNumberFormat.international,
type: PhoneNumberType.mobile,
removeCountryCodeFromMask: true,
);
expect(res, '+0 000-000-0000',
reason: 'mask should contain country code in it');
});

expect(
res,
'000-000-0000',
reason: 'mask should not contain country code in it',
);
test('with removeCountryCodeFromMask=true', () async {
final res = subj.getPhoneMask(
format: fmt,
type: PhoneNumberType.mobile,
removeCountryCodeFromMask: true);

expect(res, '000-000-0000',
reason: 'mask should not contain country code in it');
});
});
});

Expand Down

0 comments on commit 29a0724

Please sign in to comment.