mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Testing opacity style property
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import pytest
|
||||
from rich.color import Color
|
||||
from rich.style import Style
|
||||
|
||||
from textual.css.styles import Styles, RenderStyles
|
||||
from textual.dom import DOMNode
|
||||
|
||||
|
||||
def test_styles_reset():
|
||||
@@ -126,3 +128,22 @@ def test_render_styles_border():
|
||||
("", Color.default()),
|
||||
("rounded", Color.parse("green")),
|
||||
)
|
||||
|
||||
|
||||
def test_get_opacity_default():
|
||||
styles = RenderStyles(DOMNode(), Styles(), Styles())
|
||||
assert styles.opacity == 1.
|
||||
|
||||
|
||||
@pytest.mark.parametrize("set_value, expected", [
|
||||
[0.2, 0.2],
|
||||
[-0.4, 0.0],
|
||||
[5.8, 1.0],
|
||||
["25%", 0.25],
|
||||
["-10%", 0.0],
|
||||
["120%", 1.0],
|
||||
])
|
||||
def test_opacity_set_then_get(set_value, expected):
|
||||
styles = RenderStyles(DOMNode(), Styles(), Styles())
|
||||
styles.opacity = set_value
|
||||
assert styles.opacity == expected
|
||||
|
||||
Reference in New Issue
Block a user