package com.swoosh.microblog.data.model

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

class SortOrderTest {

    // --- Enum values ---

    @Test
    fun `SortOrder has exactly 3 values`() {
        assertEquals(3, SortOrder.values().size)
    }

    @Test
    fun `SortOrder valueOf works for all values`() {
        assertEquals(SortOrder.NEWEST, SortOrder.valueOf("NEWEST"))
        assertEquals(SortOrder.OLDEST, SortOrder.valueOf("OLDEST"))
        assertEquals(SortOrder.RECENTLY_UPDATED, SortOrder.valueOf("RECENTLY_UPDATED"))
    }

    // --- Display names ---

    @Test
    fun `NEWEST displayName is Newest first`() {
        assertEquals("Newest first", SortOrder.NEWEST.displayName)
    }

    @Test
    fun `OLDEST displayName is Oldest first`() {
        assertEquals("Oldest first", SortOrder.OLDEST.displayName)
    }

    @Test
    fun `RECENTLY_UPDATED displayName is Recently updated`() {
        assertEquals("Recently updated", SortOrder.RECENTLY_UPDATED.displayName)
    }

    // --- Ghost API order strings ---

    @Test
    fun `NEWEST ghostOrder is published_at desc`() {
        assertEquals("published_at desc", SortOrder.NEWEST.ghostOrder)
    }

    @Test
    fun `OLDEST ghostOrder is published_at asc`() {
        assertEquals("published_at asc", SortOrder.OLDEST.ghostOrder)
    }

    @Test
    fun `RECENTLY_UPDATED ghostOrder is updated_at desc`() {
        assertEquals("updated_at desc", SortOrder.RECENTLY_UPDATED.ghostOrder)
    }
}
