package dev.lions.unionflow.server.entity;

import dev.lions.unionflow.server.api.enums.communication.MessageStatus;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

@DisplayName("Message")
class MessageTest {

    @Test
    @DisplayName("markAsRead sets status to READ and sets readAt")
    void markAsRead_setsStatusAndReadAt() {
        Message m = new Message();
        m.setStatus(MessageStatus.SENT);
        assertThat(m.getReadAt()).isNull();

        m.markAsRead();

        assertThat(m.getStatus()).isEqualTo(MessageStatus.READ);
        assertThat(m.getReadAt()).isNotNull();
    }

    @Test
    @DisplayName("markAsEdited sets isEdited true and sets editedAt")
    void markAsEdited_setsIsEditedAndEditedAt() {
        Message m = new Message();
        assertThat(m.getIsEdited()).isFalse();
        assertThat(m.getEditedAt()).isNull();

        m.markAsEdited();

        assertThat(m.getIsEdited()).isTrue();
        assertThat(m.getEditedAt()).isNotNull();
    }
}
