Test main menu scrolling

This commit is contained in:
Yohann D'ANELLO 2020-11-06 18:32:51 +01:00
parent 60d6c7509a
commit 30a01108b8
2 changed files with 26 additions and 2 deletions

View File

@ -28,7 +28,7 @@ class MainMenu(Menu):
values = [e for e in MainMenuValues]
class ArbitraryMenu:
class ArbitraryMenu(Menu):
def __init__(self, values: list):
super().__init__(self)
super().__init__()
self.values = values

View File

@ -0,0 +1,24 @@
import unittest
from dungeonbattle.menus import ArbitraryMenu, MainMenu, MainMenuValues
class TestMenus(unittest.TestCase):
def test_scroll_menu(self) -> None:
"""
Test to scroll the menu.
"""
arbitrary_menu = ArbitraryMenu([])
self.assertEqual(arbitrary_menu.position, 0)
main_menu = MainMenu()
self.assertEqual(main_menu.position, 0)
self.assertEqual(main_menu.validate(), MainMenuValues.START)
main_menu.go_up()
self.assertEqual(main_menu.validate(), MainMenuValues.START)
main_menu.go_down()
self.assertEqual(main_menu.validate(), MainMenuValues.SETTINGS)
main_menu.go_down()
self.assertEqual(main_menu.validate(), MainMenuValues.EXIT)
main_menu.go_down()
self.assertEqual(main_menu.validate(), MainMenuValues.EXIT)