from qz.text_preprocessor import TextPreprocessor


def test_preprocess_text():
    preprocessor = TextPreprocessor()
    text = "  Hello,   World!  This is a test. With multiple sentences?  "
    result = preprocessor.preprocess_text(text)
    assert "Hello, World!" in result
    assert "This is a test." in result
    assert "With multiple sentences?" in result
    assert "  " not in result  # No double spaces


def test_split_into_chunks():
    preprocessor = TextPreprocessor()
    text = "First sentence. Second sentence. Third sentence. Fourth sentence."
    chunks = preprocessor.split_into_chunks(text, chunk_size=30)
    assert len(chunks) > 1
    assert all(len(chunk) <= 30 for chunk in chunks)
    assert all(chunk.endswith(".") for chunk in chunks)


def test_empty_text():
    preprocessor = TextPreprocessor()
    assert preprocessor.preprocess_text("") == ""
    assert not preprocessor.split_into_chunks("")  # Simplified boolean check
