diff --git a/__tests__/components/ui/select.test.tsx b/__tests__/components/ui/select.test.tsx new file mode 100644 index 0000000..a240298 --- /dev/null +++ b/__tests__/components/ui/select.test.tsx @@ -0,0 +1,217 @@ +/** + * Tests for components/ui/select.tsx + * + * Covers three key states of the primitive: + * 1. Placeholder — shown when no value is selected + * 2. Value selection — selecting an item updates the displayed value + * 3. Disabled — interaction is blocked when the select is disabled + * + * Implementation notes + * ───────────────────── + * @base-ui/react Select renders its popup via a Portal into document.body. + * jsdom supports this, so we use userEvent.click to open the popup and + * select an item exactly as a user would. + * + * Placeholder state is signalled by `data-placeholder` on SelectTrigger + * (and SelectValue), per the base-ui Select API: + * https://base-ui.com/react/components/select#trigger + * + * Disabled state is signalled by `data-disabled` on SelectTrigger and the + * native HTML `disabled` attribute on the underlying