|
1 | 1 | const React = window.React; |
2 | 2 | const ReactDOM = window.ReactDOM; |
3 | 3 |
|
| 4 | +import FixtureSet from '../../FixtureSet'; |
| 5 | +import TestCase from '../../TestCase'; |
| 6 | + |
4 | 7 | class SelectFixture extends React.Component { |
5 | 8 | state = {value: ''}; |
6 | 9 | _nestedDOMNode = null; |
@@ -31,35 +34,66 @@ class SelectFixture extends React.Component { |
31 | 34 |
|
32 | 35 | render() { |
33 | 36 | return ( |
34 | | - <form> |
35 | | - <fieldset> |
36 | | - <legend>Controlled</legend> |
37 | | - <select value={this.state.value} onChange={this.onChange}> |
38 | | - <option value="">Select a color</option> |
39 | | - <option value="red">Red</option> |
40 | | - <option value="blue">Blue</option> |
41 | | - <option value="green">Green</option> |
42 | | - </select> |
43 | | - <span className="hint">Value: {this.state.value}</span> |
44 | | - </fieldset> |
45 | | - <fieldset> |
46 | | - <legend>Uncontrolled</legend> |
47 | | - <select defaultValue=""> |
48 | | - <option value="">Select a color</option> |
49 | | - <option value="red">Red</option> |
50 | | - <option value="blue">Blue</option> |
51 | | - <option value="green">Green</option> |
52 | | - </select> |
53 | | - <span className="hint" /> |
54 | | - </fieldset> |
55 | | - <fieldset> |
56 | | - <legend>Controlled in nested subtree</legend> |
57 | | - <div ref={node => (this._nestedDOMNode = node)} /> |
58 | | - <span className="hint"> |
59 | | - This should synchronize in both direction with the one above. |
60 | | - </span> |
61 | | - </fieldset> |
62 | | - </form> |
| 37 | + <FixtureSet title="Selects" description=""> |
| 38 | + <form className="field-group"> |
| 39 | + <fieldset> |
| 40 | + <legend>Controlled</legend> |
| 41 | + <select value={this.state.value} onChange={this.onChange}> |
| 42 | + <option value="">Select a color</option> |
| 43 | + <option value="red">Red</option> |
| 44 | + <option value="blue">Blue</option> |
| 45 | + <option value="green">Green</option> |
| 46 | + </select> |
| 47 | + <span className="hint">Value: {this.state.value}</span> |
| 48 | + </fieldset> |
| 49 | + <fieldset> |
| 50 | + <legend>Uncontrolled</legend> |
| 51 | + <select defaultValue=""> |
| 52 | + <option value="">Select a color</option> |
| 53 | + <option value="red">Red</option> |
| 54 | + <option value="blue">Blue</option> |
| 55 | + <option value="green">Green</option> |
| 56 | + </select> |
| 57 | + </fieldset> |
| 58 | + </form> |
| 59 | + |
| 60 | + <TestCase title="A selected disabled option" relatedIssues="2803"> |
| 61 | + <TestCase.Steps> |
| 62 | + <li>Open the select</li> |
| 63 | + <li>Select "1"</li> |
| 64 | + <li>Attempt to reselect "Please select an item"</li> |
| 65 | + </TestCase.Steps> |
| 66 | + |
| 67 | + <TestCase.ExpectedResult> |
| 68 | + The initial picked option should be "Please select an |
| 69 | + item", however it should not be a selectable option. |
| 70 | + </TestCase.ExpectedResult> |
| 71 | + |
| 72 | + <div className="test-fixture"> |
| 73 | + <select defaultValue=""> |
| 74 | + <option value="" disabled>Please select an item</option> |
| 75 | + <option>0</option> |
| 76 | + <option>1</option> |
| 77 | + <option>2</option> |
| 78 | + </select> |
| 79 | + </div> |
| 80 | + </TestCase> |
| 81 | + |
| 82 | + <TestCase title="An unselected disabled option" relatedIssues="2803"> |
| 83 | + <TestCase.ExpectedResult> |
| 84 | + The initial picked option value should "0": the first non-disabled option. |
| 85 | + </TestCase.ExpectedResult> |
| 86 | + |
| 87 | + <div className="test-fixture"> |
| 88 | + <select defaultValue=""> |
| 89 | + <option disabled>Please select an item</option> |
| 90 | + <option>0</option> |
| 91 | + <option>1</option> |
| 92 | + <option>2</option> |
| 93 | + </select> |
| 94 | + </div> |
| 95 | + </TestCase> |
| 96 | + </FixtureSet> |
63 | 97 | ); |
64 | 98 | } |
65 | 99 | } |
|
0 commit comments