From be771a0fcaba2c9d3f6992b77c25d911d8900d4f Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Thu, 16 Jun 2022 15:47:41 +0100 Subject: [PATCH] Add extra test --- tests/css/test_stylesheet.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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`"""