test(localization): fix sentAtText, add remaining tests
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -228,15 +228,18 @@ class StreamChatLocalizationsEn extends GlobalStreamChatLocalizations {
|
||||
String get photosLabel => 'Photos';
|
||||
|
||||
String _getDay(DateTime dateTime) {
|
||||
final now = Jiffy(DateTime.now());
|
||||
final date = Jiffy(dateTime);
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final yesterday = DateTime(now.year, now.month, now.day - 1);
|
||||
|
||||
if (date.isSame(now, Units.DAY)) {
|
||||
final date = DateTime(dateTime.year, dateTime.month, dateTime.day);
|
||||
|
||||
if (date == today) {
|
||||
return 'today';
|
||||
} else if (now.diff(date, Units.HOUR) < 24) {
|
||||
} else if (date == yesterday) {
|
||||
return 'yesterday';
|
||||
} else {
|
||||
return 'on ${date.MMMd}';
|
||||
return 'on ${Jiffy(date).MMMd}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,15 +232,18 @@ class StreamChatLocalizationsFr extends GlobalStreamChatLocalizations {
|
||||
String get photosLabel => 'Photos';
|
||||
|
||||
String _getDay(DateTime dateTime) {
|
||||
final now = Jiffy(DateTime.now());
|
||||
final date = Jiffy(dateTime);
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final yesterday = DateTime(now.year, now.month, now.day - 1);
|
||||
|
||||
if (date.isSame(now, Units.DAY)) {
|
||||
final date = DateTime(dateTime.year, dateTime.month, dateTime.day);
|
||||
|
||||
if (date == today) {
|
||||
return "aujourd'hui";
|
||||
} else if (now.diff(date, Units.HOUR) < 24) {
|
||||
} else if (date == yesterday) {
|
||||
return 'hier';
|
||||
} else {
|
||||
return 'le ${date.MMMd}';
|
||||
return 'le ${Jiffy(date).MMMd}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -227,15 +227,18 @@ class StreamChatLocalizationsHi extends GlobalStreamChatLocalizations {
|
||||
String get photosLabel => 'तस्वीरें';
|
||||
|
||||
String _getDay(DateTime dateTime) {
|
||||
final now = Jiffy(DateTime.now());
|
||||
final date = Jiffy(dateTime);
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final yesterday = DateTime(now.year, now.month, now.day - 1);
|
||||
|
||||
if (date.isSame(now, Units.DAY)) {
|
||||
final date = DateTime(dateTime.year, dateTime.month, dateTime.day);
|
||||
|
||||
if (date == today) {
|
||||
return 'आज';
|
||||
} else if (now.diff(date, Units.HOUR) < 24) {
|
||||
} else if (date == yesterday) {
|
||||
return 'कल';
|
||||
} else {
|
||||
return '${date.MMMd} को';
|
||||
return '${Jiffy(date).MMMd} को';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -229,21 +229,24 @@ Il file è troppo grande per essere caricato. Il limite è di $limitInMB MB.''';
|
||||
String get photosLabel => 'Foto';
|
||||
|
||||
String _getDay(DateTime dateTime) {
|
||||
final now = Jiffy(DateTime.now());
|
||||
final date = Jiffy(dateTime);
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final yesterday = DateTime(now.year, now.month, now.day - 1);
|
||||
|
||||
if (date.isSame(now, Units.DAY)) {
|
||||
final date = DateTime(dateTime.year, dateTime.month, dateTime.day);
|
||||
|
||||
if (date == today) {
|
||||
return 'oggi';
|
||||
} else if (now.diff(date, Units.HOUR) < 24) {
|
||||
} else if (date == yesterday) {
|
||||
return 'ieri';
|
||||
} else {
|
||||
return 'il ${date.MMMd}';
|
||||
return 'il ${Jiffy(date).MMMd}';
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String sentAtText({required DateTime date, required DateTime time}) => '''
|
||||
Inviato il ${_getDay(date)} alle ${Jiffy(time.toLocal()).format('HH:mm')}''';
|
||||
String sentAtText({required DateTime date, required DateTime time}) =>
|
||||
"Inviato ${_getDay(date)} alle ${Jiffy(time.toLocal()).format('HH:mm')}";
|
||||
|
||||
@override
|
||||
String get todayLabel => 'Oggi';
|
||||
|
||||
@@ -114,6 +114,7 @@ void main() {
|
||||
isNotNull,
|
||||
);
|
||||
expect(localizations.photosLabel, isNotNull);
|
||||
// today
|
||||
expect(
|
||||
localizations.sentAtText(
|
||||
date: DateTime.now(),
|
||||
@@ -121,6 +122,22 @@ void main() {
|
||||
),
|
||||
isNotNull,
|
||||
);
|
||||
// yesterday
|
||||
expect(
|
||||
localizations.sentAtText(
|
||||
date: DateTime.now().subtract(const Duration(days: 1)),
|
||||
time: DateTime.now(),
|
||||
),
|
||||
isNotNull,
|
||||
);
|
||||
// any other day
|
||||
expect(
|
||||
localizations.sentAtText(
|
||||
date: DateTime.now().subtract(const Duration(days: 3)),
|
||||
time: DateTime.now(),
|
||||
),
|
||||
isNotNull,
|
||||
);
|
||||
expect(localizations.todayLabel, isNotNull);
|
||||
expect(localizations.yesterdayLabel, isNotNull);
|
||||
expect(localizations.channelIsMutedText, isNotNull);
|
||||
@@ -129,6 +146,7 @@ void main() {
|
||||
expect(localizations.sendingFirstMessageLabel, isNotNull);
|
||||
expect(localizations.startAChatLabel, isNotNull);
|
||||
expect(localizations.loadingChannelsError, isNotNull);
|
||||
expect(localizations.deleteConversationLabel, isNotNull);
|
||||
expect(localizations.deleteConversationQuestion, isNotNull);
|
||||
expect(localizations.streamChatLabel, isNotNull);
|
||||
expect(localizations.searchingForNetworkText, isNotNull);
|
||||
@@ -148,6 +166,7 @@ void main() {
|
||||
expect(localizations.leaveConversationLabel, isNotNull);
|
||||
expect(localizations.leaveConversationQuestion, isNotNull);
|
||||
expect(localizations.showInChatLabel, isNotNull);
|
||||
expect(localizations.saveImageLabel, isNotNull);
|
||||
expect(localizations.saveVideoLabel, isNotNull);
|
||||
expect(localizations.uploadErrorLabel, isNotNull);
|
||||
expect(localizations.giphyLabel, isNotNull);
|
||||
|
||||
Reference in New Issue
Block a user