package thb.jeanluc.adventure.loader;

import org.junit.jupiter.api.Test;
import thb.jeanluc.adventure.model.Tutorial;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

class TutorialLoaderTest {

    @Test
    void loadsTheShippedTutorial() {
        // The toy fixture is gone, so this resolves the real /world/tutorial.yaml.
        Tutorial t = new TutorialLoader().load();
        assertThat(t.isEmpty()).isFalse();
        assertThat(t.intro()).isNotBlank();
        assertThat(t.closingTips()).isNotBlank();
        assertThat(t.steps()).isNotEmpty();
        assertThat(t.steps().getFirst().expect()).isEqualTo("look");
        assertThat(t.steps().getFirst().minArgs()).isZero();
    }

    @Test
    void missingFileReturnsEmptyTutorial() {
        Tutorial t = new TutorialLoader("/no-such-base").load();
        assertThat(t.isEmpty()).isTrue();
        assertThat(t.steps()).isEmpty();
    }

    @Test
    void malformedFileThrowsWorldLoadException() {
        // /badtut/tutorial.yaml has 'steps: 12345' (scalar where a list is required)
        assertThatThrownBy(() -> new TutorialLoader("/badtut").load())
                .isInstanceOf(WorldLoadException.class);
    }
}
