diff options
author | Viljami Ilola <+@hix.fi> | 2024-04-08 19:42:21 +0300 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-04-08 19:42:21 +0300 |
commit | c99a7138e78352c4e26483dd4dad36b009a72e4f (patch) | |
tree | 77ca46af43189dd9a4863266d9149d58a52b9d0c | |
parent | 97864c921e319398db609705abf1fa916e008887 (diff) |
tests for screens
-rw-r--r-- | tests/test_screens.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/test_screens.py b/tests/test_screens.py new file mode 100644 index 0000000..a81bc33 --- /dev/null +++ b/tests/test_screens.py @@ -0,0 +1,65 @@ +import os +import unittest + +from pathlib import Path + +from text import Fonts, TextPage + +from screens import ( + gameover_screen, + hiscores_screen, + initials_screen, + instructions1_screen, + instructions2_screen, + level_screen, + levelup_screen, + mainmenu_screen) + +class TestScreens(unittest.TestCase): + def setUp(self): + Fonts.load_fonts(os.path.join( + Path(__file__).parent.parent.resolve(), + "src", + "sliceitoff")) + + def test_can_run_gameover(self): + page = gameover_screen() + self.assertEqual(TextPage, type(page)) + + def test_can_run_hiscores(self): + page = hiscores_screen("just text") + self.assertEqual(TextPage, type(page)) + + def test_can_run_initials(self): + page = initials_screen("VIL") + self.assertEqual(TextPage, type(page)) + + def test_can_run_instructions1(self): + page = instructions1_screen() + self.assertEqual(TextPage, type(page)) + + def test_can_run_instructions2(self): + page = instructions2_screen() + self.assertEqual(TextPage, type(page)) + + def test_can_run_level(self): + page = level_screen(2) + self.assertEqual(TextPage, type(page)) + + def test_can_run_levelup(self): + class mock_stats: + def __init__(self): + self.level = 1 + self.enemies = 2 + self.field_count = 3 + self.lives = 4 + self.bonus = 5 + self.percent = 5 + def calc_bonus(self): + return (1,2,3,4,5,6) + page = levelup_screen(stats=mock_stats()) + self.assertEqual(TextPage, type(page)) + + def test_can_run_mainmenu(self): + page = mainmenu_screen(2) + self.assertEqual(TextPage, type(page)) |