-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-2465 Write unit test for format date time function
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
test/features/email/presentation/extensions/calendar_event_extension_test.dart
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,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); | ||
}); | ||
}); | ||
} |