package org.raddatz.familienarchiv.user;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class PasswordResetTestHelperTest {

    @Mock PasswordResetService passwordResetService;
    @InjectMocks PasswordResetTestHelper helper;

    @Test
    void getResetTokenForTest_returnsToken_whenPresent() {
        when(passwordResetService.findLatestActiveTokenForEmail("user@example.com"))
                .thenReturn(Optional.of("abc123"));

        assertThat(helper.getResetTokenForTest("user@example.com")).contains("abc123");
    }

    @Test
    void getResetTokenForTest_returnsEmpty_whenAbsent() {
        when(passwordResetService.findLatestActiveTokenForEmail("ghost@example.com"))
                .thenReturn(Optional.empty());

        assertThat(helper.getResetTokenForTest("ghost@example.com")).isEmpty();
    }
}
