package de.trainingstagebuch.app.network

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

class SocketEventParserTest {

    @Test
    fun `parseSocketIoEvent parses known event`() {
        val parsed = SocketEventParser.parseSocketIoEvent(
            "42[\"participant:added\",{\"memberId\":1}]"
        )

        assertNotNull(parsed)
        assertEquals(SocketEventType.ParticipantAdded, parsed?.type)
        assertEquals("participant:added", parsed?.rawType)
    }

    @Test
    fun `parseSocketIoEvent returns null for non event frame`() {
        assertNull(SocketEventParser.parseSocketIoEvent("2"))
    }
}
