[ {"name": "a label and a select, submitted under its id", "args": [{"id": "sort", "label": "Sort by", "options": [{"value": "published", "label": "Recently published"}, {"value": "updated", "label": "Recently updated"}]}], "expect": "
"}, {"name": "a controlled value selects its option", "args": [{"id": "sort", "label": "Sort by", "value": "updated", "options": [{"value": "published", "label": "Recently published"}, {"value": "updated", "label": "Recently updated"}, {"value": "views", "label": "Most views"}]}], "expect": "
"}, {"name": "a default value selects its option too, under a name of its own", "args": [{"id": "s1", "name": "sortBy", "label": "Sort by", "defaultValue": "views", "options": [{"value": "updated", "label": "Recently updated"}, {"value": "views", "label": "Most views"}]}], "expect": "
"}, {"name": "a placeholder is the first option, with the value \"\"", "args": [{"id": "country", "label": "Country", "placeholder": "Choose a country", "autoComplete": "country", "options": [{"value": "GB", "label": "United Kingdom"}, {"value": "IE", "label": "Ireland"}]}], "expect": "
"}, {"name": "a value of \"\" selects the placeholder", "args": [{"id": "country", "label": "Country", "placeholder": "Choose a country", "value": "", "required": true, "options": [{"value": "GB", "label": "United Kingdom"}]}], "expect": "
"}, {"name": "hint and error: the select is described by both, hint first, and invalid", "args": [{"id": "location", "label": "Choose location", "hint": "This can be different to where you went before", "error": "Select a location", "placeholder": "", "options": [{"value": "eastmidlands", "label": "East Midlands"}, {"value": "london", "label": "London"}]}], "expect": "
This can be different to where you went before

Error: Select a location

"}, {"name": "a hint alone describes the select", "args": [{"id": "t", "label": "Title", "hint": "Optional", "options": [{"value": "mr", "label": "Mr"}, {"value": "ms", "label": "Ms"}]}], "expect": "
Optional
"}, {"name": "a disabled option and a disabled select", "args": [{"id": "plan", "label": "Plan", "disabled": true, "options": [{"value": "free", "label": "Free"}, {"value": "pro", "label": "Pro (sold out)", "disabled": true}]}], "expect": "
"}, {"name": "false booleans, empty hint and null error render nothing; a class joins the wrapper's", "args": [{"id": "p", "label": "Plan", "required": false, "disabled": false, "hint": "", "error": null, "className": "narrow", "options": [{"value": "free", "label": "Free", "disabled": false}]}], "expect": "
"}, {"name": "a value that is no option selects nothing", "args": [{"id": "p", "label": "Plan", "value": "gold", "options": [{"value": "free", "label": "Free"}, {"value": "pro", "label": "Pro"}]}], "expect": "
"}, {"name": "labels and values are escaped", "args": [{"id": "e", "label": "Q & A", "options": [{"value": "a\"b", "label": " & B"}]}], "expect": "
"}, {"name": "no options and no placeholder is still a select, empty", "args": [{"id": "none", "label": "Nothing yet", "options": []}], "expect": "
"}, {"name": "two options with one value are refused", "args": [{"id": "x", "label": "Pick", "options": [{"value": "a", "label": "A"}, {"value": "a", "label": "Also A"}]}], "expectError": "select option values must be unique: \"a\" is there twice"}, {"name": "an option with the value \"\" beside a placeholder is refused", "args": [{"id": "x", "label": "Pick", "placeholder": "Choose", "options": [{"value": "", "label": "Nothing"}]}], "expectError": "select option values must be unique: \"\" is there twice"}, {"name": "an id with a space is refused", "args": [{"id": "sort by", "label": "Sort by", "options": [{"value": "a", "label": "A"}]}], "expectError": "a field id cannot contain spaces"} ]