"""Unit tests for build/naming.py."""

from __future__ import annotations

from byteb4rb1e.sphinxcontrib.h5p.utils.pkg.build.naming import (
    directive_to_directive_class,
    directive_to_node_class,
    directive_to_snake,
    option_to_test_name,
)


class TestDirectiveToNodeClass:

    def test_true_false(self) -> None:
        assert directive_to_node_class("h5p-true-false") == \
            "h5p_true_false"

    def test_multi_choice(self) -> None:
        assert directive_to_node_class("h5p-multi-choice") == \
            "h5p_multi_choice"

    def test_single_segment(self) -> None:
        assert directive_to_node_class("h5p") == "h5p"

    def test_child_directive(self) -> None:
        assert directive_to_node_class(
            "h5p-multi-choice-option",
        ) == "h5p_multi_choice_option"


class TestDirectiveToDirectiveClass:

    def test_true_false(self) -> None:
        assert directive_to_directive_class("h5p-true-false") == \
            "H5PTrueFalseDirective"

    def test_multi_choice(self) -> None:
        assert directive_to_directive_class("h5p-multi-choice") == \
            "H5PMultiChoiceDirective"

    def test_question_set(self) -> None:
        assert directive_to_directive_class("h5p-question-set") == \
            "H5PQuestionSetDirective"

    def test_child_directive(self) -> None:
        assert directive_to_directive_class(
            "h5p-multi-choice-option",
        ) == "H5PMultiChoiceOptionDirective"


class TestDirectiveToSnake:

    def test_true_false(self) -> None:
        assert directive_to_snake("h5p-true-false") == \
            "h5p_true_false"

    def test_question_set(self) -> None:
        assert directive_to_snake("h5p-question-set") == \
            "h5p_question_set"

    def test_font_awesome(self) -> None:
        assert directive_to_snake("font-awesome") == \
            "font_awesome"


class TestOptionToTestName:

    def test_enable_retry(self) -> None:
        assert option_to_test_name("enable-retry") == \
            "enable_retry"

    def test_confirm_check_dialog(self) -> None:
        assert option_to_test_name("confirm-check-dialog") == \
            "confirm_check_dialog"

    def test_single_word(self) -> None:
        assert option_to_test_name("correct") == "correct"

    def test_negated(self) -> None:
        assert option_to_test_name("no-enable-retry") == \
            "no_enable_retry"
