diff --git a/test/recurrence_rule_test.dart b/test/recurrence_rule_test.dart index d054aff..944fec1 100644 --- a/test/recurrence_rule_test.dart +++ b/test/recurrence_rule_test.dart @@ -1,9 +1,17 @@ +import 'package:intl/date_symbol_data_local.dart'; +import 'package:intl/intl.dart'; import 'package:rrule/rrule.dart'; import 'package:rrule/src/cache.dart'; import 'package:rrule/src/utils.dart'; import 'package:test/test.dart'; +import 'codecs/text/utils.dart'; +import 'codecs/utils.dart'; + void main() { + late final RruleL10n l10n; + setUpAll(() async => l10n = await RruleL10nEn.create()); + group('copyWith', () { test('until can be adjusted', () { expect( @@ -204,4 +212,41 @@ void main() { equals(start), ); }); + group( + '#59: It cannot parse its own strings when current locale does not use Latin numbers', + () { + setUp(() async { + Intl.defaultLocale = 'ar'; + await initializeDateFormatting(); + }); + + tearDown(() async { + Intl.defaultLocale = 'en'; + await initializeDateFormatting(); + }); + + final rrule = RecurrenceRule( + frequency: Frequency.daily, + until: DateTime.utc(1997, 12, 24), + ); + const string = 'RRULE:FREQ=DAILY;UNTIL=19971224T000000Z'; + const text = 'Daily, until Wednesday, December 24, 1997 12:00:00 AM'; + + testStringCodec( + 'StringCodec', + codec: const RecurrenceRuleStringCodec( + toStringOptions: RecurrenceRuleToStringOptions(isTimeUtc: true), + ), + value: rrule, + string: string, + ); + + testText( + 'TextCodec', + text: text, + string: string, + l10n: () => l10n, + ); + }, + ); } diff --git a/test/rrule_ical_test.dart b/test/rrule_ical_test.dart index 7d737c6..6d7c3ac 100644 --- a/test/rrule_ical_test.dart +++ b/test/rrule_ical_test.dart @@ -18,7 +18,6 @@ void main() { required DateTime start, required Iterable expected, bool isInfinite = false, - bool testNonLatin = false, }) { utils.testRrule( description, @@ -29,29 +28,9 @@ void main() { expected: expected, isInfinite: isInfinite, l10n: () => l10n, - testNonLatin: testNonLatin, ); } - // Non-latin tests - testRrule( - 'Daily until December 24, 1997 - Non-Latin', - string: 'RRULE:FREQ=DAILY;UNTIL=19971224T000000Z', - text: 'Daily, until Wednesday, December 24, 1997 12:00:00 AM', - rrule: RecurrenceRule( - frequency: Frequency.daily, - until: DateTime.utc(1997, 12, 24), - ), - start: DateTime.utc(1997, 9, 2, 9, 0, 0), - expected: [ - ...2.until(31).map((d) => DateTime.utc(1997, 9, d, 9, 0, 0)), - ...1.until(32).map((d) => DateTime.utc(1997, 10, d, 9, 0, 0)), - ...1.until(31).map((d) => DateTime.utc(1997, 11, d, 9, 0, 0)), - ...1.until(24).map((d) => DateTime.utc(1997, 12, d, 9, 0, 0)), - ], - testNonLatin: true, - ); - // All examples taken from https://tools.ietf.org/html/rfc5545#section-3.8.5.3. // - Some RRULE-strings had some fields reordered to match the production rule // (recur-rule-part) order and remain consistent. The original string is diff --git a/test/utils.dart b/test/utils.dart index 5bb6ce3..ebf90e5 100644 --- a/test/utils.dart +++ b/test/utils.dart @@ -1,5 +1,3 @@ -import 'package:intl/date_symbol_data_local.dart'; -import 'package:intl/intl.dart'; import 'package:meta/meta.dart'; import 'package:rrule/rrule.dart'; import 'package:test/test.dart'; @@ -19,23 +17,8 @@ void testRrule( required Iterable expected, bool isInfinite = false, required RruleL10n Function() l10n, - bool testNonLatin = false, }) { group(description, () { - setUp(() async { - if (testNonLatin) { - Intl.defaultLocale = 'ar'; - await initializeDateFormatting(); - } - }); - - tearDown(() async { - if (testNonLatin) { - Intl.defaultLocale = 'en'; - await initializeDateFormatting(); - } - }); - testStringCodec( 'StringCodec', codec: const RecurrenceRuleStringCodec(