package de.trainingstagebuch.app.utils

import de.trainingstagebuch.app.R
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test

class AuthInputValidatorTest {

    @Test
    fun `validateLogin returns error for missing fields`() {
        assertEquals(
            R.string.error_required_login_fields,
            AuthInputValidator.validateLogin("", "secret")
        )
    }

    @Test
    fun `validateRegister returns null for valid input`() {
        assertNull(
            AuthInputValidator.validateRegister("user@test.de", "secret", "secret")
        )
    }

    @Test
    fun `validateForgotPassword returns error for blank email`() {
        assertEquals(
            R.string.error_required_email,
            AuthInputValidator.validateForgotPassword(" ")
        )
    }

    @Test
    fun `validateResetPassword returns mismatch error`() {
        assertEquals(
            R.string.error_password_mismatch,
            AuthInputValidator.validateResetPassword(
                token = "token123",
                password = "secret1",
                confirmPassword = "secret2"
            )
        )
    }

    @Test
    fun `validateResetPassword returns too short error`() {
        assertEquals(
            R.string.error_password_too_short,
            AuthInputValidator.validateResetPassword(
                token = "token123",
                password = "12345",
                confirmPassword = "12345"
            )
        )
    }

    @Test
    fun `validateResetPassword returns null for valid input`() {
        assertNull(
            AuthInputValidator.validateResetPassword(
                token = "token123",
                password = "123456",
                confirmPassword = "123456"
            )
        )
    }
}
