-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,333 additions
and
34 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
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,170 @@ | ||
import 'package:get_time_ago/get_time_ago.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
final messages = ArabicMessages(); | ||
|
||
group('ArabicMessages Test', () { | ||
test('prefixAgo should return "قبل"', () { | ||
expect(messages.prefixAgo(), 'قبل'); | ||
}); | ||
|
||
test('suffixAgo should return empty string', () { | ||
expect(messages.suffixAgo(), ''); | ||
}); | ||
|
||
test('justNow should return "الآن"', () { | ||
expect(messages.justNow(10), 'الآن'); | ||
}); | ||
|
||
test('secsAgo should return correct seconds ago format', () { | ||
expect(messages.secsAgo(5), '۵ ثوان'); | ||
}); | ||
|
||
test('minAgo should return "دقيقة واحدة"', () { | ||
expect(messages.minAgo(1), 'دقيقة واحدة'); | ||
}); | ||
|
||
test('minsAgo should return correct plural form for 2 minutes', () { | ||
expect(messages.minsAgo(2), 'دقيقتين'); | ||
}); | ||
|
||
test('minsAgo should return correct plural form for more than 2 minutes', | ||
() { | ||
expect(messages.minsAgo(5), '۵ دقائق'); | ||
}); | ||
|
||
test('hourAgo should return "ساعة واحدة"', () { | ||
expect(messages.hourAgo(60), 'ساعة واحدة'); | ||
}); | ||
|
||
test('hoursAgo should return correct plural form for 2 hours', () { | ||
expect(messages.hoursAgo(2), 'ساعتين'); | ||
}); | ||
|
||
test('hoursAgo should return correct plural form for more than 2 hours', | ||
() { | ||
expect(messages.hoursAgo(5), '۵ ساعات'); | ||
}); | ||
|
||
test('dayAgo should return "يوم واحد"', () { | ||
expect(messages.dayAgo(24), 'يوم واحد'); | ||
}); | ||
|
||
test('daysAgo should return correct plural form for 2 days', () { | ||
expect(messages.daysAgo(2), 'يومين'); | ||
}); | ||
|
||
test('daysAgo should return correct plural form for more than 2 days', () { | ||
expect(messages.daysAgo(5), '۵ أيام'); | ||
}); | ||
|
||
test('wordSeparator should return a space', () { | ||
expect(messages.wordSeparator(), ' '); | ||
}); | ||
}); | ||
|
||
// Helper function to get the DateTime relative to now | ||
DateTime _getRelativeDateTime(Duration duration) { | ||
return DateTime.now().subtract(duration); | ||
} | ||
|
||
group('GetTimeAgo Test with Arabic Locale', () { | ||
test('should return الآن for time less than 15 seconds', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(seconds: 0)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'الآن'); | ||
}); | ||
|
||
test('should return correct format for 30 seconds ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(seconds: 30)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'قبل ۳۰ ثوان'); | ||
}); | ||
|
||
test('should return دقيقة واحدة for 1 minute ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(minutes: 1)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'قبل دقيقة واحدة'); | ||
}); | ||
|
||
test('should return دقيقتين for 2 minutes ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(minutes: 2)), | ||
locale: 'ar', | ||
); | ||
print(result.toString() == 'قبل دقيقتين'); | ||
expect(result, 'قبل دقيقتين'); | ||
}); | ||
|
||
test('should return correct format for 5 minutes ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(minutes: 5)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'قبل ۵ دقائق'); | ||
}); | ||
|
||
test('should return ساعة واحدة for 1 hour ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(hours: 1)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'قبل ساعة واحدة'); | ||
}); | ||
|
||
test('should return ساعتين for 2 hours ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(hours: 2)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'قبل ساعتين'); | ||
}); | ||
|
||
test('should return correct format for 5 hours ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(hours: 5)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'قبل ۵ ساعات'); | ||
}); | ||
|
||
test('should return يوم واحد for 1 day ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(days: 1)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'قبل يوم واحد'); | ||
}); | ||
|
||
test('should return يومين for 2 days ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(days: 2)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'قبل يومين'); | ||
}); | ||
|
||
test('should return correct format for 5 days ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(days: 5)), | ||
locale: 'ar', | ||
); | ||
expect(result, 'قبل ۵ أيام'); | ||
}); | ||
|
||
test('should return formatted date for dates beyond 7 days', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(days: 10)), | ||
locale: 'ar', | ||
); | ||
expect(result, isNot('قبل ۱۰ أيام')); | ||
}); | ||
}); | ||
} |
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,131 @@ | ||
import 'package:get_time_ago/get_time_ago.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
final messages = GermanMessages(); | ||
|
||
group('GermanMessages Test', () { | ||
test('prefixAgo should return "vor"', () { | ||
expect(messages.prefixAgo(), 'vor'); | ||
}); | ||
|
||
test('suffixAgo should return an empty string', () { | ||
expect(messages.suffixAgo(), ''); | ||
}); | ||
|
||
test('justNow should return "vorhin"', () { | ||
expect(messages.justNow(10), 'vorhin'); | ||
}); | ||
|
||
test('secsAgo should return correct seconds ago format', () { | ||
expect(messages.secsAgo(25), '25 Sekunden'); | ||
}); | ||
|
||
test('minAgo should return "einer Minute"', () { | ||
expect(messages.minAgo(1), 'einer Minute'); | ||
}); | ||
|
||
test('minsAgo should return correct minutes ago format', () { | ||
expect(messages.minsAgo(5), '5 Minuten'); | ||
}); | ||
|
||
test('hourAgo should return "einer Stunde"', () { | ||
expect(messages.hourAgo(60), 'einer Stunde'); | ||
}); | ||
|
||
test('hoursAgo should return correct hours ago format', () { | ||
expect(messages.hoursAgo(5), '5 Stunden'); | ||
}); | ||
|
||
test('dayAgo should return "einem Tag"', () { | ||
expect(messages.dayAgo(24), 'einem Tag'); | ||
}); | ||
|
||
test('daysAgo should return correct days ago format', () { | ||
expect(messages.daysAgo(5), '5 Tagen'); | ||
}); | ||
|
||
test('wordSeparator should return a space', () { | ||
expect(messages.wordSeparator(), ' '); | ||
}); | ||
}); | ||
|
||
// Helper function to get the DateTime relative to now | ||
DateTime _getRelativeDateTime(Duration duration) { | ||
return DateTime.now().subtract(duration); | ||
} | ||
|
||
group('GetTimeAgo Test with German Locale', () { | ||
test('should return vorhin for time less than 15 seconds', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(seconds: 0)), | ||
locale: 'de', | ||
); | ||
expect(result, 'vorhin'); | ||
}); | ||
|
||
test('should return correct format for seconds ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(seconds: 20)), | ||
locale: 'de', | ||
); | ||
expect(result, 'vor 20 Sekunden'); | ||
}); | ||
|
||
test('should return einer Minute for 1 minute ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(minutes: 1)), | ||
locale: 'de', | ||
); | ||
expect(result, 'vor einer Minute'); | ||
}); | ||
|
||
test('should return correct format for 5 minutes ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(minutes: 5)), | ||
locale: 'de', | ||
); | ||
expect(result, 'vor 5 Minuten'); | ||
}); | ||
|
||
test('should return einer Stunde for 1 hour ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(hours: 1)), | ||
locale: 'de', | ||
); | ||
expect(result, 'vor einer Stunde'); | ||
}); | ||
|
||
test('should return correct format for 5 hours ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(hours: 5)), | ||
locale: 'de', | ||
); | ||
expect(result, 'vor 5 Stunden'); | ||
}); | ||
|
||
test('should return einem Tag for 1 day ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(days: 1)), | ||
locale: 'de', | ||
); | ||
expect(result, 'vor einem Tag'); | ||
}); | ||
|
||
test('should return correct format for 5 days ago', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(days: 5)), | ||
locale: 'de', | ||
); | ||
expect(result, 'vor 5 Tagen'); | ||
}); | ||
|
||
test('should return formatted date for dates beyond 7 days', () { | ||
final result = GetTimeAgo.parse( | ||
_getRelativeDateTime(const Duration(days: 10)), | ||
locale: 'de', | ||
); | ||
expect(result, isNot('vor 10 Tagen')); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.