Skip to content

Commit a32be5f

Browse files
committed
tests: Test that brand-backed themes compile without error
1 parent efcb11f commit a32be5f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/pytest/test_theme.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,33 @@ def test_theme_add_sass_layer_file():
257257
assert theme._defaults == ["// defaults 1\n// defaults 2\n"]
258258
assert theme._mixins == ["// mixins\n"]
259259
assert theme._rules == ["// rules 1\n// rules 2\n"]
260+
261+
@skip_on_windows
262+
@pytest.mark.parametrize("preset", shiny_theme_presets)
263+
def test_theme_from_brand_base_case_compiles(preset: str):
264+
brand_txt = f"""
265+
meta:
266+
name: Brand Test
267+
defaults:
268+
shiny:
269+
theme:
270+
preset: {preset}
271+
"""
272+
273+
with tempfile.TemporaryDirectory() as tmpdir:
274+
with open(f"{tmpdir}/_brand.yml", "w") as f:
275+
f.write(brand_txt)
276+
277+
theme = Theme.from_brand(f"{tmpdir}")
278+
279+
# Check that the theme preset is set from the brand
280+
assert theme.preset == preset
281+
282+
# Check that the brand Sass layer is included
283+
assert any(["brand-choose" in f for f in theme._functions])
284+
assert any(["brand: initial" in d for d in theme._defaults])
285+
assert any(["brand: brand rules" in r for r in theme._rules])
286+
287+
# Check that the CSS compiles without error
288+
css = theme.to_css()
289+
assert isinstance(css, str)

0 commit comments

Comments
 (0)