package thb.jeanluc.adventure.io.text;

import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;

class RenderingsTest {

    @Test
    void roomToStyledText_includesNameDescriptionItemsNpcsExits() {
        RoomView room = new RoomView("Kitchen", "A cold kitchen.",
                List.of("Lamp", "Letter"), List.of("Old Man"), List.of("north", "east"));

        String text = Renderings.roomToStyledText(room).plainText();

        assertThat(text).contains("Kitchen");
        assertThat(text).contains("A cold kitchen.");
        assertThat(text).contains("Lamp").contains("Letter");
        assertThat(text).contains("Old Man");
        assertThat(text).contains("north").contains("east");
    }

    @Test
    void roomToStyledText_noExits_saysNoObviousExits() {
        RoomView room = new RoomView("Void", "Nothing.", List.of(), List.of(), List.of());
        assertThat(Renderings.roomToStyledText(room).plainText())
                .contains("no obvious exits");
    }

    @Test
    void roomToStyledText_tagsItemSpansWithItemStyle() {
        RoomView room = new RoomView("Kitchen", "desc",
                List.of("Lamp"), List.of(), List.of("north"));
        boolean hasItemSpan = Renderings.roomToStyledText(room).spans().stream()
                .anyMatch(s -> s.style() == Style.ITEM && s.text().equals("Lamp"));
        assertThat(hasItemSpan).isTrue();
    }
}
