Add extra test

This commit is contained in:
Darren Burns
2022-06-16 15:47:41 +01:00
parent 4dd0d9fae4
commit be771a0fca

View File

@@ -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`"""