package com.ponzischeme89.memby.ui.alerts

import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test

class AlertsFormatTest {
    @Test
    fun `no alerts wears no badge`() {
        assertNull(alertBadgeLabel(0))
        assertNull(alertBadgeLabel(-1))
    }

    @Test
    fun `a small count is drawn as itself`() {
        assertEquals("1", alertBadgeLabel(1))
        assertEquals("9", alertBadgeLabel(9))
    }

    @Test
    fun `a large count stops counting rather than widening the pill`() {
        assertEquals("9+", alertBadgeLabel(10))
        assertEquals("9+", alertBadgeLabel(240))
    }

    @Test
    fun `the summary counts alerts, and names the new ones only when there are some`() {
        assertEquals("Nothing waiting for you", alertsSummary(total = 0, unread = 0))
        assertEquals("1 alert", alertsSummary(total = 1, unread = 0))
        assertEquals("4 alerts", alertsSummary(total = 4, unread = 0))
        assertEquals("4 alerts · 2 new", alertsSummary(total = 4, unread = 2))
        assertEquals("1 alert · 1 new", alertsSummary(total = 1, unread = 1))
    }
}
