import numpy as np

from spectraforge.core.indices import compute_index, get_indices


def test_compute_index_ndvi() -> None:
    nir = np.array([1.0, 2.0], dtype="float32")
    red = np.array([1.0, 1.0], dtype="float32")
    out = compute_index("(NIR - RED) / (NIR + RED)", {"NIR": nir, "RED": red})
    expected = np.array([0.0, 1.0 / 3.0], dtype="float32")
    assert np.allclose(out, expected, atol=1e-6)


def test_get_indices_contains_ndvi() -> None:
    names = {idx.name for idx in get_indices("Sentinel-2")}
    assert "NDVI" in names
