package com.ponzischeme89.memby.ui

import com.ponzischeme89.memby.data.model.BaseItem
import com.ponzischeme89.memby.ui.detail.franchiseStart
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test

class DetailFranchiseTest {
    private fun movie(id: String, year: Int, collection: String? = "The Saga") = BaseItem(
        id = id,
        name = "Movie $id",
        type = "Movie",
        productionYear = year,
        collectionName = collection,
    )

    @Test
    fun `earliest movie in the same collection starts the franchise`() {
        val current = movie("three", 2022)
        val start = franchiseStart(
            current,
            listOf(movie("two", 2018), movie("one", 2014), movie("other", 2001, "Other")),
        )

        assertEquals("The Saga", start?.name)
        assertEquals("one", start?.firstMovie?.id)
    }

    @Test
    fun `a collection name without a sibling is not presented as a franchise`() {
        assertNull(franchiseStart(movie("only", 2020), emptyList()))
    }
}
