"""Tests para from_jsonl."""

import pytest

from from_jsonl import from_jsonl


def test_jsonl_valido():
    text = '{"a": 1}\n{"b": 2}'
    result = from_jsonl(text)
    assert result == [{"a": 1}, {"b": 2}]


def test_lineas_vacias_intercaladas():
    text = '{"x": 1}\n\n{"x": 2}\n\n'
    result = from_jsonl(text)
    assert len(result) == 2
    assert result[0] == {"x": 1}
    assert result[1] == {"x": 2}


def test_linea_invalida_raise_con_numero():
    text = '{"ok": 1}\nnot-json\n{"ok": 3}'
    with pytest.raises(ValueError, match="linea 2"):
        from_jsonl(text)
