Skip to content

Commit

Permalink
test_buttons: Add test for PMButton button text.
Browse files Browse the repository at this point in the history
  • Loading branch information
theViz343 committed Mar 17, 2023
1 parent a825956 commit 0623252
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/ui_tools/test_buttons.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

import pytest
Expand All @@ -13,6 +14,7 @@
EmojiButton,
MessageLinkButton,
ParsedNarrowLink,
PMButton,
StarredButton,
StreamButton,
TopButton,
Expand Down Expand Up @@ -178,6 +180,17 @@ def test_update_widget(
set_attr_map.assert_called_once_with({None: top_button.label_style})


class TestPMButton:
def test_button_text(self, mocker: MockerFixture, count: int = 10) -> None:
pm_button = PMButton(controller=mocker.Mock(), count=count)
title_text = pm_button.label_text[:-3].strip()
hotkey_text = pm_button.label_text[-3:]
# regex checks fixed length = 20, title capitalization, and presence of hotkey
pattern = re.compile(r"(?=.{20}$)[A-Z].{1,15}[ ]{1,16}\[.\]")
assert pattern.match(pm_button.label_text), "Button text does not match regex"
assert title_text == "Direct messages" and hotkey_text == "[P]"


class TestStarredButton:
def test_count_style_init_argument_value(
self, mocker: MockerFixture, count: int = 10
Expand Down

0 comments on commit 0623252

Please sign in to comment.