Skip to content

Commit

Permalink
Updated to v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nixrajput committed Sep 15, 2024
1 parent 0c3e348 commit 12f4dc2
Show file tree
Hide file tree
Showing 12 changed files with 1,052 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/src/messages/languages/tr_msg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TurkishMessages implements Messages {

/// Message for when the elapsed time is about a minute.
@override
String minAgo(int minutes) => '1 dakika önce';
String minAgo(int minutes) => '1 dakika';

/// Message for when the elapsed time is in minutes.
@override
Expand Down
2 changes: 1 addition & 1 deletion test/messages/language/fa_msg_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void main() {
DateTime.now().subtract(const Duration(days: 10)),
locale: 'fa',
);
expect(result, isNot('\u202B ۳ روز پیش'));
expect(result, isNot('\u202B ۱۰ روز پیش'));
});
});
}
2 changes: 1 addition & 1 deletion test/messages/language/ja_msg_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void main() {
return DateTime.now().subtract(duration);
}

group('GetTimeAgo tests with JapaneseMessages', () {
group('GetTimeAgo Test with Japanese Locale', () {
test('should return "唯今" for time less than 15 seconds', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(seconds: 5)),
Expand Down
131 changes: 131 additions & 0 deletions test/messages/language/ko_msg_test.dart
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 koreanMessages = KoreanMessages();

group('KoreanMessages Test', () {
test('prefixAgo should return an empty string', () {
expect(koreanMessages.prefixAgo(), '');
});

test('suffixAgo should return "전"', () {
expect(koreanMessages.suffixAgo(), '전');
});

test('justNow should return "바로 지금"', () {
expect(koreanMessages.justNow(10), '바로 지금');
});

test('secsAgo should return correct seconds ago format', () {
expect(koreanMessages.secsAgo(30), '30초');
});

test('minAgo should return "일분"', () {
expect(koreanMessages.minAgo(1), '일분');
});

test('minsAgo should return correct minutes ago format', () {
expect(koreanMessages.minsAgo(5), '5분');
});

test('hourAgo should return "한시간"', () {
expect(koreanMessages.hourAgo(60), '한시간');
});

test('hoursAgo should return correct hours ago format', () {
expect(koreanMessages.hoursAgo(3), '3시간');
});

test('dayAgo should return "하루"', () {
expect(koreanMessages.dayAgo(24), '하루');
});

test('daysAgo should return correct days ago format', () {
expect(koreanMessages.daysAgo(2), '2일');
});

test('wordSeparator should return an empty string', () {
expect(koreanMessages.wordSeparator(), '');
});
});

// Helper function to get the DateTime relative to now
DateTime _getRelativeDateTime(Duration duration) {
return DateTime.now().subtract(duration);
}

group('GetTimeAgo Test with Korean Locale', () {
test('should return "바로 지금" for time less than 15 seconds', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(seconds: 5)),
locale: 'ko',
);
expect(result, '바로 지금');
});

test('should return "20초전" for 20 seconds ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(seconds: 20)),
locale: 'ko',
);
expect(result, '20초전');
});

test('should return "일분전" for 1 minute ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(minutes: 1)),
locale: 'ko',
);
expect(result, '일분전');
});

test('should return "2분전" for 2 minutes ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(minutes: 2)),
locale: 'ko',
);
expect(result, '2분전');
});

test('should return "한시간전" for 1 hour ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(hours: 1)),
locale: 'ko',
);
expect(result, '한시간전');
});

test('should return "2시간전" for 2 hours ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(hours: 2)),
locale: 'ko',
);
expect(result, '2시간전');
});

test('should return "하루전" for 1 day ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(hours: 24)),
locale: 'ko',
);
expect(result, '하루전');
});

test('should return "3일전" for 3 days ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(days: 3)),
locale: 'ko',
);
expect(result, '3일전');
});

test('should return formatted date for dates beyond 7 days', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(days: 10)),
locale: 'ko',
);
expect(result, isNot('10일전'));
});
});
}
131 changes: 131 additions & 0 deletions test/messages/language/oc_msg_test.dart
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 occitanMessages = OccitanMessages();

group('OccitanMessages Test', () {
test('prefixAgo should return "fa"', () {
expect(occitanMessages.prefixAgo(), 'fa');
});

test('suffixAgo should return an empty string', () {
expect(occitanMessages.suffixAgo(), '');
});

test('justNow should return "just ara"', () {
expect(occitanMessages.justNow(10), 'just ara');
});

test('secsAgo should return correct seconds ago format', () {
expect(occitanMessages.secsAgo(30), '30 segondas');
});

test('minAgo should return "una minuta"', () {
expect(occitanMessages.minAgo(1), 'una minuta');
});

test('minsAgo should return correct minutes ago format', () {
expect(occitanMessages.minsAgo(5), '5 minutas');
});

test('hourAgo should return "una ora"', () {
expect(occitanMessages.hourAgo(60), 'una ora');
});

test('hoursAgo should return correct hours ago format', () {
expect(occitanMessages.hoursAgo(3), '3 oras');
});

test('dayAgo should return "un jorn"', () {
expect(occitanMessages.dayAgo(24), 'un jorn');
});

test('daysAgo should return correct days ago format', () {
expect(occitanMessages.daysAgo(2), '2 jors');
});

test('wordSeparator should return a space', () {
expect(occitanMessages.wordSeparator(), ' ');
});
});

// Helper function to get the DateTime relative to now
DateTime _getRelativeDateTime(Duration duration) {
return DateTime.now().subtract(duration);
}

group('GetTimeAgo Test with Occitan Locale', () {
test('should return "just ara" for time less than 15 seconds', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(seconds: 5)),
locale: 'oc',
);
expect(result, 'just ara');
});

test('should return "20 segondas fa" for 20 seconds ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(seconds: 20)),
locale: 'oc',
);
expect(result, 'fa 20 segondas');
});

test('should return "una minuta fa" for 1 minute ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(minutes: 1)),
locale: 'oc',
);
expect(result, 'fa una minuta');
});

test('should return "2 minutas fa" for 2 minutes ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(minutes: 2)),
locale: 'oc',
);
expect(result, 'fa 2 minutas');
});

test('should return "una ora fa" for 1 hour ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(hours: 1)),
locale: 'oc',
);
expect(result, 'fa una ora');
});

test('should return "2 oras fa" for 2 hours ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(hours: 2)),
locale: 'oc',
);
expect(result, 'fa 2 oras');
});

test('should return "un jorn fa" for 1 day ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(hours: 24)),
locale: 'oc',
);
expect(result, 'fa un jorn');
});

test('should return "3 jors fa" for 3 days ago', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(days: 3)),
locale: 'oc',
);
expect(result, 'fa 3 jors');
});

test('should return formatted date for dates beyond 7 days', () {
final result = GetTimeAgo.parse(
_getRelativeDateTime(const Duration(days: 10)),
locale: 'oc',
);
expect(result, isNot('fa 3 jors'));
});
});
}
Loading

0 comments on commit 12f4dc2

Please sign in to comment.