From d6fb9140515fa7cfcc8ca883be4ec7b9cb0c44e4 Mon Sep 17 00:00:00 2001 From: Cavin Date: Sun, 27 Sep 2026 09:16:42 +0300 Subject: [PATCH] chore(test): add idependent tests for time util component --- .../gatelog/common/time/TimeUtilTest.kt | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/test/kotlin/io/github/devcavin/gatelog/common/time/TimeUtilTest.kt diff --git a/src/test/kotlin/io/github/devcavin/gatelog/common/time/TimeUtilTest.kt b/src/test/kotlin/io/github/devcavin/gatelog/common/time/TimeUtilTest.kt new file mode 100644 index 0000000..2462031 --- /dev/null +++ b/src/test/kotlin/io/github/devcavin/gatelog/common/time/TimeUtilTest.kt @@ -0,0 +1,41 @@ +package io.github.devcavin.gatelog.common.time + +import org.junit.jupiter.api.Test +import java.time.Clock +import java.time.OffsetDateTime +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class TimeUtilTest { + val clock: Clock = Clock.systemDefaultZone() + val timeUtil = TimeUtil(clock) + + @Test + fun `checkin time yesterday is overnight`() { + val checkinTime = OffsetDateTime.parse("2026-09-26T20:00:00Z") + val now = OffsetDateTime.parse("2026-09-27T00:00:00Z") + + val result = timeUtil.isOvernight(checkinTime, now) + + assertTrue(result) + } + + @Test + fun `checkin time today is not overnight`() { + val checkinTime = OffsetDateTime.parse("2026-09-26T20:00:00Z") + val now = OffsetDateTime.parse("2026-09-26T23:59:59Z") + + val result = timeUtil.isOvernight(checkinTime, now) + + assertFalse(result) + } + + @Test + fun `checkin time previous day is overnight`() { + val checkinTime = OffsetDateTime.parse("2026-09-24T23:59:59Z") + val now = OffsetDateTime.parse("2026-09-25T00:00:00Z") + + val result = timeUtil.isOvernight(checkinTime, now) + assertTrue(result) + } +} \ No newline at end of file