mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Using console.get_style, adding test ensuring style applies
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
from rich.style import Style
|
||||
|
||||
from tests.utilities.render import render
|
||||
from textual.renderables.underline_bar import UnderlineBar
|
||||
|
||||
MAGENTA = "\x1b[35m"
|
||||
GREY = "\x1b[38;5;59m"
|
||||
STOP = "\x1b[0m"
|
||||
GREEN = "\x1b[32m"
|
||||
RED = "\x1b[31m"
|
||||
|
||||
|
||||
def test_no_highlight():
|
||||
@@ -110,13 +110,17 @@ def test_highlight_full_range_out_of_bounds_start():
|
||||
assert render(bar) == f"{GREY}━━━━━━{STOP}"
|
||||
|
||||
|
||||
def test_init_with_str_style():
|
||||
bar = UnderlineBar(background_style="green", highlight_style="yellow")
|
||||
assert bar.background_style == Style(color="green")
|
||||
assert bar.highlight_style == Style(color="yellow")
|
||||
|
||||
|
||||
def test_init_with_object_style():
|
||||
bar = UnderlineBar(background_style=Style(color="green"), highlight_style=Style(color="yellow"))
|
||||
assert bar.background_style == Style(color="green")
|
||||
assert bar.highlight_style == Style(color="yellow")
|
||||
def test_custom_styles():
|
||||
bar = UnderlineBar(
|
||||
highlight_range=(2, 4),
|
||||
highlight_style="red",
|
||||
background_style="green",
|
||||
width=6
|
||||
)
|
||||
assert render(bar) == (
|
||||
f"{GREEN}━{STOP}"
|
||||
f"{GREEN}╸{STOP}"
|
||||
f"{RED}━━{STOP}"
|
||||
f"{GREEN}╺{STOP}"
|
||||
f"{GREEN}━{STOP}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user