diff --git a/tests/css/test_stylesheet.py b/tests/css/test_stylesheet.py index eaaa57b4f..c9bac2a68 100644 --- a/tests/css/test_stylesheet.py +++ b/tests/css/test_stylesheet.py @@ -8,6 +8,7 @@ from textual.css._help_renderables import HelpText from textual.css.stylesheet import Stylesheet, StylesheetParseError from textual.css.tokenizer import TokenizeError from textual.dom import DOMNode +from textual.geometry import Spacing 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) +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(): """When we use two selectors containing only classes, then the selector `.b.c` has greater specificity than the selector `.a`"""