TF-2465 Write unit test for format date time function

(cherry picked from commit 56ace6b1a4683bd346170b6b982157bea9255dc0)
This commit is contained in:
hieubt
2024-01-18 17:57:39 +07:00
committed by Dat H. Pham
parent f93b23bb4f
commit 3ff19c1b08
@@ -0,0 +1,30 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:date_format/date_format.dart' as date_format;
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
import 'package:tmail_ui_user/features/email/presentation/extensions/calendar_event_extension.dart';
void main() {
group('calendar event extension test', () {
final dateTime = DateTime(2021, 10, 10, 10, 30, 00, 00, 00);
const locale = date_format.EnglishDateLocale();
const expectedFormattedDateTime = 'Sunday, October 10, 2021 10:30 AM';
const expectedFormattedTime = '10:30 AM';
test('formatDateTime should return a string with format DD, MM dd, yyy hh:nn am', () {
final calendarEvent = CalendarEvent(startDate: dateTime);
final formattedDateTime = calendarEvent.formatDateTime(locale, dateTime);
expect(formattedDateTime, expectedFormattedDateTime);
});
test('formatTime should return a string with format hh:nn', () {
final calendarEvent = CalendarEvent(startDate: dateTime);
final formattedTime = calendarEvent.formatTime(locale, dateTime);
expect(formattedTime, expectedFormattedTime);
});
});
}