aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_tui.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/tests/test_tui.py')
-rw-r--r--app/tests/test_tui.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/tests/test_tui.py b/app/tests/test_tui.py
index 7c9c800..5b5cb3c 100644
--- a/app/tests/test_tui.py
+++ b/app/tests/test_tui.py
@@ -227,6 +227,33 @@ class MenuTests(TuiTestCase):
with self.assertRaises(tui.WizardCancelled):
tui.menu(screen, "Pick", self.OPTIONS)
+ def test_separator_is_blank_and_skipped_by_cursor(self):
+ options = [("build", "build"), tui.MENU_SEPARATOR,
+ ("quit", "quit")]
+ # Down from the first option must skip the blank divider and land on
+ # the third option (Enter returns its value, not the separator's).
+ screen = FakeScreen(keys=[FakeCurses.KEY_DOWN, 10])
+ self.assertEqual(tui.menu(screen, "Pick", options), "quit")
+
+ def test_separator_alone_is_rejected(self):
+ with self.assertRaises(ValueError):
+ tui.menu(self.screen, "Pick", [tui.MENU_SEPARATOR])
+
+ def test_suffix_renders_in_its_theme_color(self):
+ # default_index=1 keeps the suffixed option unselected, so its
+ # segments keep their own colors instead of the cursor bar.
+ options = [("Build audio.cpp server", "build",
+ ("[recommended]", "warn")), ("other", "other")]
+ screen = FakeScreen(keys=[10])
+ tui.menu(screen, "Pick", options, default_index=1)
+ text = " [recommended]"
+ attr = next(a for _, _, drawn, a in screen.strings
+ if drawn == text)
+ self.assertEqual(attr, tui._THEME["warn"])
+ label_attr = next(a for _, _, drawn, a in screen.strings
+ if drawn == "Build audio.cpp server")
+ self.assertEqual(label_attr, tui._THEME["body"])
+
class MenuTableTests(TuiTestCase):
"""The optional status table: aligned columns and colored statuses."""