Skip to content

Commit

Permalink
test(date_time_extension): add test cases for isToday-like methods
Browse files Browse the repository at this point in the history
  • Loading branch information
albertms10 committed Jan 27, 2023
1 parent 1fde056 commit 63b2c88
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/utils/date_time_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,29 @@ void main() {
expect(DateTime(2021, 1, 10, 9, 30).toDouble(), closeTo(18637.3, 0.1));
});
});

group('.isToday', () {
test('should return whether this DateTime is today', () {
final dateTime = DateTime(1970, 1, 10, 9, 30);
expect(dateTime.isToday, isFalse);
expect(DateTime.now().isToday, isTrue);
});
});

group('.isYesterday', () {
test('should return whether this DateTime is yesterday', () {
expect(DateTime.now().isYesterday, isFalse);
final dateTime = DateTime.now().subtract(const Duration(days: 1));
expect(dateTime.isYesterday, isTrue);
});
});

group('.isTomorrow', () {
test('should return whether this DateTime is tomorrow', () {
expect(DateTime.now().isTomorrow, isFalse);
final dateTime = DateTime.now().add(const Duration(days: 1));
expect(dateTime.isTomorrow, isTrue);
});
});
});
}

0 comments on commit 63b2c88

Please sign in to comment.