mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add extra test
This commit is contained in:
@@ -8,6 +8,7 @@ from textual.css._help_renderables import HelpText
|
|||||||
from textual.css.stylesheet import Stylesheet, StylesheetParseError
|
from textual.css.stylesheet import Stylesheet, StylesheetParseError
|
||||||
from textual.css.tokenizer import TokenizeError
|
from textual.css.tokenizer import TokenizeError
|
||||||
from textual.dom import DOMNode
|
from textual.dom import DOMNode
|
||||||
|
from textual.geometry import Spacing
|
||||||
|
|
||||||
|
|
||||||
def _make_stylesheet(css: str) -> Stylesheet:
|
def _make_stylesheet(css: str) -> Stylesheet:
|
||||||
@@ -27,6 +28,16 @@ def test_stylesheet_apply_highest_specificity_wins():
|
|||||||
assert node.styles.color == Color(255, 0, 0)
|
assert node.styles.color == Color(255, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
|
def test_stylesheet_apply_doesnt_override_defaults():
|
||||||
|
css = "#id {color: red;}"
|
||||||
|
stylesheet = _make_stylesheet(css)
|
||||||
|
node = DOMNode(id="id")
|
||||||
|
stylesheet.apply(node)
|
||||||
|
|
||||||
|
assert node.styles.margin == Spacing.all(0)
|
||||||
|
assert node.styles.box_sizing == "border-box"
|
||||||
|
|
||||||
|
|
||||||
def test_stylesheet_apply_highest_specificity_wins_multiple_classes():
|
def test_stylesheet_apply_highest_specificity_wins_multiple_classes():
|
||||||
"""When we use two selectors containing only classes, then the selector
|
"""When we use two selectors containing only classes, then the selector
|
||||||
`.b.c` has greater specificity than the selector `.a`"""
|
`.b.c` has greater specificity than the selector `.a`"""
|
||||||
|
|||||||
Reference in New Issue
Block a user