"""
Tests for engine.viewport module.
"""

from engine import viewport


class TestViewportTw:
    """Tests for tw() function."""

    def test_tw_returns_int(self):
        """tw() returns an integer."""
        result = viewport.tw()
        assert isinstance(result, int)

    def test_tw_positive(self):
        """tw() returns a positive value."""
        assert viewport.tw() > 0


class TestViewportTh:
    """Tests for th() function."""

    def test_th_returns_int(self):
        """th() returns an integer."""
        result = viewport.th()
        assert isinstance(result, int)

    def test_th_positive(self):
        """th() returns a positive value."""
        assert viewport.th() > 0


class TestViewportMoveTo:
    """Tests for move_to() function."""

    def test_move_to_format(self):
        """move_to() returns correctly formatted ANSI escape."""
        result = viewport.move_to(5, 10)
        assert result == "\033[5;10H"

    def test_move_to_default_col(self):
        """move_to() defaults to column 1."""
        result = viewport.move_to(5)
        assert result == "\033[5;1H"


class TestViewportClearScreen:
    """Tests for clear_screen() function."""

    def test_clear_screen_format(self):
        """clear_screen() returns clear screen ANSI escape."""
        result = viewport.clear_screen()
        assert "\033[2J" in result
        assert "\033[H" in result


class TestViewportClearLine:
    """Tests for clear_line() function."""

    def test_clear_line_format(self):
        """clear_line() returns clear line ANSI escape."""
        result = viewport.clear_line()
        assert result == "\033[K"
