package com.swoosh.microblog.data.model

import org.junit.Assert.*
import org.junit.Test

class PostFilterTest {

    // --- Enum values ---

    @Test
    fun `PostFilter has exactly 5 values`() {
        assertEquals(5, PostFilter.values().size)
    }

    @Test
    fun `PostFilter valueOf works for all values`() {
        assertEquals(PostFilter.ALL, PostFilter.valueOf("ALL"))
        assertEquals(PostFilter.PUBLISHED, PostFilter.valueOf("PUBLISHED"))
        assertEquals(PostFilter.DRAFT, PostFilter.valueOf("DRAFT"))
        assertEquals(PostFilter.SCHEDULED, PostFilter.valueOf("SCHEDULED"))
        assertEquals(PostFilter.SENT, PostFilter.valueOf("SENT"))
    }

    // --- Display names ---

    @Test
    fun `ALL displayName is All`() {
        assertEquals("All", PostFilter.ALL.displayName)
    }

    @Test
    fun `PUBLISHED displayName is Published`() {
        assertEquals("Published", PostFilter.PUBLISHED.displayName)
    }

    @Test
    fun `DRAFT displayName is Drafts`() {
        assertEquals("Drafts", PostFilter.DRAFT.displayName)
    }

    @Test
    fun `SCHEDULED displayName is Scheduled`() {
        assertEquals("Scheduled", PostFilter.SCHEDULED.displayName)
    }

    // --- Ghost API filter strings ---

    @Test
    fun `ALL ghostFilter is null`() {
        assertNull(PostFilter.ALL.ghostFilter)
    }

    @Test
    fun `PUBLISHED ghostFilter is status_published`() {
        assertEquals("status:published", PostFilter.PUBLISHED.ghostFilter)
    }

    @Test
    fun `DRAFT ghostFilter is status_draft`() {
        assertEquals("status:draft", PostFilter.DRAFT.ghostFilter)
    }

    @Test
    fun `SCHEDULED ghostFilter is status_scheduled`() {
        assertEquals("status:scheduled", PostFilter.SCHEDULED.ghostFilter)
    }

    // --- toPostStatus mapping ---

    @Test
    fun `ALL toPostStatus returns null`() {
        assertNull(PostFilter.ALL.toPostStatus())
    }

    @Test
    fun `PUBLISHED toPostStatus returns PostStatus PUBLISHED`() {
        assertEquals(PostStatus.PUBLISHED, PostFilter.PUBLISHED.toPostStatus())
    }

    @Test
    fun `DRAFT toPostStatus returns PostStatus DRAFT`() {
        assertEquals(PostStatus.DRAFT, PostFilter.DRAFT.toPostStatus())
    }

    @Test
    fun `SCHEDULED toPostStatus returns PostStatus SCHEDULED`() {
        assertEquals(PostStatus.SCHEDULED, PostFilter.SCHEDULED.toPostStatus())
    }

    // --- Empty messages ---

    @Test
    fun `ALL emptyMessage returns No posts yet`() {
        assertEquals("No posts yet", PostFilter.ALL.emptyMessage())
    }

    @Test
    fun `PUBLISHED emptyMessage returns No published posts yet`() {
        assertEquals("No published posts yet", PostFilter.PUBLISHED.emptyMessage())
    }

    @Test
    fun `DRAFT emptyMessage returns No drafts yet`() {
        assertEquals("No drafts yet", PostFilter.DRAFT.emptyMessage())
    }

    @Test
    fun `SCHEDULED emptyMessage returns No scheduled posts yet`() {
        assertEquals("No scheduled posts yet", PostFilter.SCHEDULED.emptyMessage())
    }

    // --- SENT filter ---

    @Test
    fun `SENT displayName is Sent`() {
        assertEquals("Sent", PostFilter.SENT.displayName)
    }

    @Test
    fun `SENT ghostFilter is status_sent`() {
        assertEquals("status:sent", PostFilter.SENT.ghostFilter)
    }

    @Test
    fun `SENT toPostStatus returns PostStatus SENT`() {
        assertEquals(PostStatus.SENT, PostFilter.SENT.toPostStatus())
    }

    @Test
    fun `SENT emptyMessage returns No sent newsletters yet`() {
        assertEquals("No sent newsletters yet", PostFilter.SENT.emptyMessage())
    }
}
