import { describe, it, expect } from 'vitest'
import { isCotFirstByte, COT_FIRST_BYTE_TAK, COT_FIRST_BYTE_XML } from '../../server/utils/cotParser.js'

describe('cotRouter', () => {
  describe('isCotFirstByte', () => {
    it.each([
      [0xBF, true],
      [COT_FIRST_BYTE_TAK, true],
      [0x3C, true],
      [COT_FIRST_BYTE_XML, true],
    ])('returns true for valid COT bytes: 0x%02X', (byte, expected) => {
      expect(isCotFirstByte(byte)).toBe(expected)
    })

    it.each([
      [0x47, false], // 'G' GET
      [0x50, false], // 'P' POST
      [0x48, false], // 'H' HEAD
      [0x00, false],
      [0x16, false], // TLS client hello
    ])('returns false for non-COT bytes: 0x%02X', (byte, expected) => {
      expect(isCotFirstByte(byte)).toBe(expected)
    })
  })
})
