Skip to content

Commit

Permalink
check schedule date when day is the same as current day but different…
Browse files Browse the repository at this point in the history
… month
  • Loading branch information
ferdyrod committed May 30, 2024
1 parent 2d3b4e7 commit f5bf20c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/src/test/java/org/dhis2/bindings/DateExtensionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ class DateExtensionsTest {
assert(date.toOverdueOrScheduledUiText(resourceManager, currentDate) == "Today")
}

@Test
fun `Should return 'In x days', when the scheduled date is same day but more than 3 month and same year`() {
val currentDate = currentCalendar().time
val date: Date? = currentCalendar().apply {
add(Calendar.MONTH, 1)
}.time
whenever(resourceManager.getPlural(R.plurals.schedule_days, 30, 30)) doReturn "In 30 days"
assert(date.toOverdueOrScheduledUiText(resourceManager, currentDate) == "In 30 days")
}

@Test
fun `Should return 'In x days', when the current date is -x days from the scheduled date and less than 90 days`() {
val currentDate = currentCalendar().time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fun Date?.toOverdueOrScheduledUiText(
)
}

period.days in 1..89 -> {
period.days in 0..89 && period.months in 1..3 -> {
val intervalDays = if (this.time > currentDay.time) {
Interval(currentDay.time, this.time)
} else {
Expand Down

0 comments on commit f5bf20c

Please sign in to comment.