from datasets import Dataset

from data_measurements.measurements import TextDuplicates


def test_text_duplicates_initialize(mock_load_metric):
    TextDuplicates(feature=None)
    mock_load_metric.assert_called_once_with("text_duplicates")


def test_text_duplicates_run(mock_load_metric):
    dataset = Dataset.from_dict({"text": ["Hello", "World", "Hello", "Foo Bar"]})
    text_duplicates = TextDuplicates(feature="text")
    text_duplicates.measure(dataset)

    text_duplicates.metric.compute.assert_called_once_with(data=dataset["text"])
