aboutsummaryrefslogtreecommitdiff
path: root/tests/gallery-probes/test_dupre_merge.py
blob: 891b789bc616ca143ee4918ea91c7553dc977939 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""The settings-casting widget candidates live in the canonical Dupre kit."""

import os
import unittest


ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))


def source(name):
    with open(os.path.join(ROOT, "docs", "prototypes", name)) as handle:
        return handle.read()


class DupreMergeTests(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.widgets = source("widgets.js")
        cls.additions = source("dupre-kit-additions.js")
        cls.gallery = source("panel-widget-gallery.html")

    def test_three_candidates_are_owned_only_by_the_canonical_kit(self):
        for name in ("detentFader", "drumRoller", "guardedToggle"):
            declaration = f"DUPRE.{name} = function"
            self.assertEqual(self.widgets.count(declaration), 1, name)
            self.assertNotIn(declaration, self.additions, name)

    def test_detent_fader_brings_its_styles_and_policy(self):
        self.assertIn(".dupre-dfader{", self.widgets)
        self.assertIn("DUPRE.detentFader.POLICY", self.widgets)

    def test_drum_supports_any_channel_count_and_configurable_range(self):
        for fragment in (
            "opts.min !== undefined",
            "opts.max !== undefined",
            "opts.height !== undefined",
            "chans.forEach((c, i) => set(i, c.v))",
        ):
            self.assertIn(fragment, self.widgets)

    def test_guarded_toggle_throws_through_the_viewer_plane(self):
        self.assertIn("lever.style.transformBox = 'view-box'", self.widgets)
        self.assertIn("'rotateX(180deg)'", self.widgets)

    def test_gallery_specifies_detent_and_multichannel_drum(self):
        self.assertIn("card(C,'A1','Detent fader'", self.gallery)
        self.assertIn("channels:[{name:'HIGH'", self.gallery)
        self.assertIn("{name:'MID'", self.gallery)
        self.assertIn("{name:'LOW'", self.gallery)


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