diff options
Diffstat (limited to 'android/app/src/test/java/org/terst/doot')
| -rw-r--r-- | android/app/src/test/java/org/terst/doot/widget/ui/TaskDetailActivityTest.kt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/android/app/src/test/java/org/terst/doot/widget/ui/TaskDetailActivityTest.kt b/android/app/src/test/java/org/terst/doot/widget/ui/TaskDetailActivityTest.kt new file mode 100644 index 0000000..94a5ce9 --- /dev/null +++ b/android/app/src/test/java/org/terst/doot/widget/ui/TaskDetailActivityTest.kt @@ -0,0 +1,39 @@ +package org.terst.doot.widget.ui + +import org.junit.Assert.assertEquals +import org.junit.Test +import java.time.LocalDate + +class TaskDetailActivityTest { + + private val anchor = LocalDate.of(2026, 8, 6) // Thursday + + @Test + fun `postponeDate tomorrow is a single day ahead`() { + assertEquals("2026-08-07", postponeDate(PostponePeriod.TOMORROW, anchor)) + } + + @Test + fun `postponeDate next week is seven days ahead`() { + assertEquals("2026-08-13", postponeDate(PostponePeriod.NEXT_WEEK, anchor)) + } + + @Test + fun `postponeDate next month is a calendar month ahead`() { + assertEquals("2026-09-06", postponeDate(PostponePeriod.NEXT_MONTH, anchor)) + } + + @Test + fun `postponeDate next month across a short month clamps -- NOT the same as the Go server's overflow behavior`() { + // Verified, not assumed: java.time.LocalDate.plusMonths CLAMPS to the target + // month's last valid day (Jan 31 -> Feb 28), unlike + // ComputeNextOccurrence (internal/models/recurrence.go)'s Go time.AddDate, + // which OVERFLOWS instead (Jan 31 + 1 month -> Mar 3). This is a real, + // known divergence between this client-side postpone helper and the + // server's recurrence date math for day-of-month 29-31 -- not something + // this fix reconciles, just documenting it accurately instead of + // asserting the wrong behavior. + val jan31 = LocalDate.of(2026, 1, 31) + assertEquals("2026-02-28", postponeDate(PostponePeriod.NEXT_MONTH, jan31)) + } +} |
