package com.hermes.app.core.gestures

import kotlin.test.Test
import kotlin.test.assertFalse
import kotlin.test.assertTrue

class HermesSwipeDownDetectorTest {
    @Test
    fun triggersAfterCumulativeDownwardDrag() {
        val detector = HermesSwipeDownDetector(threshold = 32f)

        assertFalse(detector.onDrag(10f))
        assertFalse(detector.onDrag(10f))
        assertTrue(detector.onDrag(12f))
    }

    @Test
    fun doesNotTriggerForSmallOrUpwardDrags() {
        val detector = HermesSwipeDownDetector(threshold = 32f)

        assertFalse(detector.onDrag(20f))
        assertFalse(detector.onDrag(-15f))
        assertFalse(detector.onDrag(20f))
    }

    @Test
    fun onlyTriggersOncePerGestureUntilReset() {
        val detector = HermesSwipeDownDetector(threshold = 32f)

        assertTrue(detector.onDrag(40f))
        assertFalse(detector.onDrag(40f))

        detector.reset()

        assertTrue(detector.onDrag(40f))
    }
}
