tests: added last unit tests, removed unused ui test dependencies

This commit is contained in:
vantablackTea
2026-09-16 00:15:33 +03:00
parent 4160a79574
commit aa568cb628
4 changed files with 115 additions and 8 deletions
@@ -0,0 +1,72 @@
package agzam.vyatsu.domain.model
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Test
import java.time.LocalDate
class ScheduleTest {
private val autumnPeriod = SchedulePeriod(
weekStart = LocalDate.of(2026, 9, 14),
weekEnd = LocalDate.of(2026, 9, 27),
season = Season.AUTUMN
)
private val nextPeriod = SchedulePeriod(
weekStart = LocalDate.of(2026, 9, 28),
weekEnd = LocalDate.of(2026, 10, 11),
season = Season.AUTUMN
)
private val dayInFirstPeriod = Day(LocalDate.of(2026, 9, 15), emptyList())
private val dayInSecondPeriod = Day(LocalDate.of(2026, 9, 29), emptyList())
private val dayOutsidePeriods = Day(LocalDate.of(2026, 10, 20), emptyList())
private val schedule = Schedule(
groupId = "12345",
periods = listOf(autumnPeriod, nextPeriod),
days = listOf(dayInFirstPeriod, dayInSecondPeriod, dayOutsidePeriods)
)
@Test
fun periodOf_matchesDateInsidePeriod() {
assertEquals(autumnPeriod, schedule.periodOf(LocalDate.of(2026, 9, 15)))
}
@Test
fun periodOf_includesBothBounds() {
assertEquals(autumnPeriod, schedule.periodOf(autumnPeriod.weekStart))
assertEquals(autumnPeriod, schedule.periodOf(autumnPeriod.weekEnd))
assertEquals(nextPeriod, schedule.periodOf(nextPeriod.weekStart))
assertEquals(nextPeriod, schedule.periodOf(nextPeriod.weekEnd))
}
@Test
fun periodOf_returnsNullForDateOutsideAllPeriods() {
assertNull(schedule.periodOf(LocalDate.of(2026, 10, 20)))
}
@Test
fun daysOf_returnsOnlyDaysWithinPeriod() {
assertEquals(listOf(dayInFirstPeriod), schedule.daysOf(autumnPeriod))
assertEquals(listOf(dayInSecondPeriod), schedule.daysOf(nextPeriod))
}
@Test
fun daysOf_returnsEmptyWhenPeriodHasNoDays() {
val emptyPeriod = SchedulePeriod(
weekStart = LocalDate.of(2027, 1, 4),
weekEnd = LocalDate.of(2027, 1, 17),
season = Season.SPRING
)
assertEquals(emptyList<Day>(), schedule.daysOf(emptyPeriod))
}
@Test
fun daysOf_neverReturnsDayOutsideEveryPeriod() {
val collected = schedule.periods.flatMap { schedule.daysOf(it) }
assertFalse(collected.contains(dayOutsidePeriods))
}
}