aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_theme.py
blob: 5f2f533b44b54da78272df7c92c83719ad38d7f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))

import unittest

import deckit.theme as theme

PALETTE = """* {
    base:      #24273aff;
    text:      #cad3f5ff;
    surface0:  #363a4fff;
}"""
ACCENT = "* { accent: #b7bdf8; }"


class Theme(unittest.TestCase):
    def test_parses_palette(self):
        self.assertEqual(theme.parse_palette(PALETTE),
                         {"base": "#24273aff", "text": "#cad3f5ff", "surface0": "#363a4fff"})

    def test_parses_accent(self):
        self.assertEqual(theme.parse_accent(ACCENT), "#b7bdf8")
        self.assertIsNone(theme.parse_accent("nothing"))

    def test_css_exposes_vars_and_falls_back(self):
        out = theme.css({"base": "#24273a"}, None)
        self.assertIn("--udt-base: #24273a", out)
        self.assertIn("--udt-accent:", out)  # fallback accent


if __name__ == "__main__":
    unittest.main()