Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/ui/context_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class ContextMenuShortcut(Span, CoreComponent):
@classmethod
def create(cls, *children, **props) -> Span:
props["data-slot"] = "context-menu-shortcut"
props["class_name"] = ClassNames.SHORTCUT
cls.set_class_name(ClassNames.SHORTCUT, props)
return super().create(*children, **props)


Expand Down
34 changes: 34 additions & 0 deletions tests/test_context_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys
from pathlib import Path

ROOT_DIR = Path(__file__).parent.parent
sys.path.insert(0, str(ROOT_DIR))

from components.ui.context_menu import ClassNames, ContextMenuShortcut # noqa: E402


def test_context_menu_shortcut_uses_default_classes() -> None:
shortcut = ContextMenuShortcut.create("Ctrl+C")

assert ClassNames.SHORTCUT in str(shortcut.class_name)


def test_context_menu_shortcut_merges_custom_class_name() -> None:
shortcut = ContextMenuShortcut.create("Ctrl+C", class_name="custom-shortcut")

assert ClassNames.SHORTCUT in str(shortcut.class_name)
assert "custom-shortcut" in str(shortcut.class_name)


def test_context_menu_shortcut_unstyled_omits_default_classes() -> None:
shortcut = ContextMenuShortcut.create("Ctrl+C", unstyled=True)

assert str(shortcut.class_name) == ""


def test_context_menu_shortcut_unstyled_keeps_custom_class_name() -> None:
shortcut = ContextMenuShortcut.create(
"Ctrl+C", class_name="custom-shortcut", unstyled=True
)

assert str(shortcut.class_name) == "custom-shortcut"
Loading