[ {"fn": "toggleValue", "name": "ticking the first box", "args": [[{"value": "a", "label": "A"}, {"value": "b", "label": "B"}, {"value": "c", "label": "C"}], [], "a", true], "expect": ["a"]}, {"fn": "toggleValue", "name": "ticking keeps the options' order, not the click order", "args": [[{"value": "a", "label": "A"}, {"value": "b", "label": "B"}, {"value": "c", "label": "C"}], ["c"], "a", true], "expect": ["a", "c"]}, {"fn": "toggleValue", "name": "clearing a box removes only it", "args": [[{"value": "a", "label": "A"}, {"value": "b", "label": "B"}, {"value": "c", "label": "C"}], ["a", "b", "c"], "b", false], "expect": ["a", "c"]}, {"fn": "toggleValue", "name": "clearing the last box leaves an empty list", "args": [[{"value": "a", "label": "A"}, {"value": "b", "label": "B"}], ["b"], "b", false], "expect": []}, {"fn": "toggleValue", "name": "ticking a box already ticked lists it once", "args": [[{"value": "a", "label": "A"}, {"value": "b", "label": "B"}], ["b", "a"], "a", true], "expect": ["a", "b"]}, {"fn": "toggleValue", "name": "clearing a box that was not ticked only puts the list in order", "args": [[{"value": "a", "label": "A"}, {"value": "b", "label": "B"}, {"value": "c", "label": "C"}], ["c", "a"], "b", false], "expect": ["a", "c"]}, {"fn": "toggleValue", "name": "duplicates and values no longer offered drop out", "args": [[{"value": "a", "label": "A"}, {"value": "b", "label": "B"}], ["b", "old", "b"], "a", false], "expect": ["b"]}, {"fn": "toggleValue", "name": "ticking the exclusive None clears every other box", "args": [[{"value": "france", "label": "France"}, {"value": "spain", "label": "Spain"}, {"value": "none", "label": "None of these", "exclusive": true, "divider": "or"}], ["france", "spain"], "none", true], "expect": ["none"]}, {"fn": "toggleValue", "name": "ticking another box clears the exclusive None", "args": [[{"value": "france", "label": "France"}, {"value": "spain", "label": "Spain"}, {"value": "none", "label": "None of these", "exclusive": true}], ["none"], "spain", true], "expect": ["spain"]}, {"fn": "toggleValue", "name": "clearing the exclusive None leaves nothing ticked", "args": [[{"value": "france", "label": "France"}, {"value": "none", "label": "None", "exclusive": true}], ["none"], "none", false], "expect": []}, {"fn": "toggleValue", "name": "exclusive false is an ordinary option", "args": [[{"value": "a", "label": "A", "exclusive": false}, {"value": "b", "label": "B", "exclusive": false}], ["a"], "b", true], "expect": ["a", "b"]}, {"fn": "toggleValue", "name": "a value that is not an option is refused", "args": [[{"value": "a", "label": "A"}], ["a"], "z", true], "expectError": "\"z\" is not one of the checkbox options"}, {"fn": "CheckboxGroup", "name": "a legend and three checkboxes: the first takes the id, the rest -2 and -3", "args": [{"id": "waste", "legend": "Which types of waste do you transport?", "options": [{"value": "carcasses", "label": "Waste from animal carcasses"}, {"value": "mines", "label": "Waste from mines or quarries"}, {"value": "farm", "label": "Farm or agricultural waste"}]}], "expect": "
"}, {"fn": "CheckboxGroup", "name": "controlled values tick their boxes", "args": [{"id": "c", "name": "colours", "legend": "Colours", "values": ["blue"], "options": [{"value": "red", "label": "Red"}, {"value": "blue", "label": "Blue"}]}], "expect": ""}, {"fn": "CheckboxGroup", "name": "default values tick their boxes too", "args": [{"id": "c", "legend": "Colours", "defaultValues": ["red", "blue"], "options": [{"value": "red", "label": "Red"}, {"value": "blue", "label": "Blue"}]}], "expect": ""}, {"fn": "CheckboxGroup", "name": "a hint describes the group; an item hint describes its own box", "args": [{"id": "nationality", "legend": "What is your nationality?", "hint": "Select all that apply", "options": [{"value": "british", "label": "British", "hint": "including English, Scottish, Welsh and Northern Irish"}, {"value": "irish", "label": "Irish"}]}], "expect": ""}, {"fn": "CheckboxGroup", "name": "an error describes the fieldset, not each box", "args": [{"id": "n", "legend": "Nationality", "error": "Select your nationality", "options": [{"value": "british", "label": "British"}, {"value": "irish", "label": "Irish"}]}], "expect": ""}, {"fn": "CheckboxGroup", "name": "an exclusive None after an or divider", "args": [{"id": "countries", "legend": "Will you travel to any of these countries?", "values": ["none"], "options": [{"value": "france", "label": "France"}, {"value": "none", "label": "No, none of these", "divider": "or", "exclusive": true}]}], "expect": ""}, {"fn": "CheckboxGroup", "name": "small, disabled options and the legend as page heading", "args": [{"id": "f", "legend": "Filter", "isPageHeading": true, "small": true, "options": [{"value": "open", "label": "Open"}, {"value": "closed", "label": "Closed", "disabled": true}]}], "expect": ""}, {"fn": "CheckboxGroup", "name": "disabled disables every box; a class name joins the wrapper's", "args": [{"id": "d", "legend": "Days", "disabled": true, "className": "wide", "options": [{"value": "mon", "label": "Monday"}, {"value": "tue", "label": "Tuesday", "disabled": false}]}], "expect": ""}, {"fn": "CheckboxGroup", "name": "labels and values are escaped", "args": [{"id": "e", "legend": "Q & A", "options": [{"value": "a&b", "label": " & \"B\""}]}], "expect": ""}, {"fn": "CheckboxGroup", "name": "no options is refused", "args": [{"id": "x", "legend": "Pick", "options": []}], "expectError": "a checkbox group needs at least one option"}, {"fn": "CheckboxGroup", "name": "two options with one value are refused", "args": [{"id": "x", "legend": "Pick", "options": [{"value": "a", "label": "A"}, {"value": "a", "label": "Also A"}]}], "expectError": "checkbox option values must be unique: \"a\" is there twice"}, {"fn": "CheckboxGroup", "name": "an id with a space is refused", "args": [{"id": "my waste", "legend": "Waste", "options": [{"value": "a", "label": "A"}]}], "expectError": "a field id cannot contain spaces"} ]