"""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()