39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
# Copyright (c) 2025 Patrick Motsch
|
|
# All rights reserved.
|
|
import pytest
|
|
from modules.serviceCenter.services.serviceGeneration.styleDefaults import resolveStyle, DEFAULT_STYLE
|
|
|
|
|
|
def test_resolve_none_returns_defaults():
|
|
result = resolveStyle(None)
|
|
assert result == DEFAULT_STYLE
|
|
|
|
|
|
def test_resolve_empty_returns_defaults():
|
|
result = resolveStyle({})
|
|
assert result == DEFAULT_STYLE
|
|
|
|
|
|
def test_override_single_color():
|
|
result = resolveStyle({"colors": {"primary": "#FF0000"}})
|
|
assert result["colors"]["primary"] == "#FF0000"
|
|
assert result["colors"]["secondary"] == DEFAULT_STYLE["colors"]["secondary"]
|
|
|
|
|
|
def test_override_nested_heading():
|
|
result = resolveStyle({"headings": {"h1": {"sizePt": 30}}})
|
|
assert result["headings"]["h1"]["sizePt"] == 30
|
|
assert result["headings"]["h1"]["weight"] == "bold"
|
|
|
|
|
|
def test_override_font():
|
|
result = resolveStyle({"fonts": {"primary": "Arial"}})
|
|
assert result["fonts"]["primary"] == "Arial"
|
|
assert result["fonts"]["monospace"] == "Consolas"
|
|
|
|
|
|
def test_full_style_passthrough():
|
|
custom = {"fonts": {"primary": "Helvetica", "monospace": "Monaco"}}
|
|
result = resolveStyle(custom)
|
|
assert result["fonts"]["primary"] == "Helvetica"
|
|
assert result["fonts"]["monospace"] == "Monaco"
|