Add a regression test for #12200 (#12242)
* fix selectedIndex in postMountWrapper in ReactDOMFiberSelected * comment in ReactDomFiberSelect in postMountWrapper for selectedIndex fix * test for selectedIndex fix * set boolean value for multiple * Revert the fix which has been fixed on master
Gareth Small committed
Aug 3, 2018 at 10:10 UTC
75491a8f4b5924424b94198e7a56b3519f6430c6
1 file changed
+16
packages/react-dom/src/__tests__/ReactDOMSelect-test.js
+16
@@ -792,4 +792,20 @@ describe('ReactDOMSelect', () => {
792
793
document.body.removeChild(container);
794
});
795
+
796
+ it('should not select first option by default when multiple is set and no defaultValue is set', () => {
797
+ const stub = (
798
+ <select multiple={true} onChange={noop}>
799
+ <option value="a">a</option>
800
+ <option value="b">b</option>
801
+ <option value="c">c</option>
802
+ </select>
803
+ );
804
+ const container = document.createElement('div');
805
+ const node = ReactDOM.render(stub, container);
806
+
807
+ expect(node.options[0].selected).toBe(false); // a
808
+ expect(node.options[1].selected).toBe(false); // b
809
+ expect(node.options[2].selected).toBe(false); // c
810
+ });
811
});