Fixed FormattingRules not being applied
This commit is contained in:
@@ -350,3 +350,32 @@ class TestPresets:
|
||||
|
||||
assert "background-color: purple" in css.css
|
||||
assert "color: yellow" in css.css
|
||||
|
||||
def test_i_can_expand_rule_preset_via_style(self):
|
||||
"""A rule preset referenced via style() must be expanded like via format().
|
||||
|
||||
Why: style("traffic_light") should expand the traffic_light rule preset
|
||||
(which has conditional style rules) instead of looking up "traffic_light"
|
||||
as a style preset name (where it doesn't exist).
|
||||
"""
|
||||
engine = FormattingEngine()
|
||||
rules = [FormatRule(style=Style(preset="traffic_light"))]
|
||||
|
||||
css, _ = engine.apply_format(rules, cell_value=-5)
|
||||
|
||||
assert css is not None
|
||||
assert css.cls == "mf-formatting-error"
|
||||
|
||||
def test_i_can_expand_rule_preset_via_style_with_no_match(self):
|
||||
"""A rule preset via style() with a non-matching condition returns no style.
|
||||
|
||||
Why: traffic_light has style("error") only if value < 0.
|
||||
A positive value should produce no style output.
|
||||
"""
|
||||
engine = FormattingEngine()
|
||||
rules = [FormatRule(style=Style(preset="traffic_light"))]
|
||||
|
||||
css, _ = engine.apply_format(rules, cell_value=10)
|
||||
|
||||
assert css is not None
|
||||
assert css.cls == "mf-formatting-success"
|
||||
|
||||
Reference in New Issue
Block a user