1111
1212const ReactDOMServerIntegrationUtils = require ( './utils/ReactDOMServerIntegrationTestUtils' ) ;
1313
14+ const TEXT_NODE_TYPE = 3 ;
15+
1416let React ;
1517let ReactDOM ;
1618let ReactDOMServer ;
@@ -37,6 +39,8 @@ const {
3739 itClientRenders,
3840 renderIntoDom,
3941 serverRender,
42+ streamRender,
43+ clientRenderOnServerString,
4044} = ReactDOMServerIntegrationUtils ( initModules ) ;
4145
4246describe ( 'ReactDOMServerIntegration' , ( ) => {
@@ -45,6 +49,11 @@ describe('ReactDOMServerIntegration', () => {
4549 } ) ;
4650
4751 describe ( 'form controls' , function ( ) {
52+ function expectNode ( node , type , value ) {
53+ expect ( node ) . not . toBe ( null ) ;
54+ expect ( node . nodeType ) . toBe ( type ) ;
55+ expect ( node . nodeValue ) . toMatch ( value ) ;
56+ }
4857 describe ( 'inputs' , function ( ) {
4958 itRenders ( 'an input with a value and an onChange' , async render => {
5059 const e = await render ( < input value = "foo" onChange = { ( ) => { } } /> ) ;
@@ -341,6 +350,31 @@ describe('ReactDOMServerIntegration', () => {
341350 ) ;
342351 } ) ;
343352
353+ describe ( 'options' , function ( ) {
354+ itRenders ( 'an option with multiple text children' , async render => {
355+ const e = await render (
356+ < select value = "bar" readOnly = { true } >
357+ < option value = "bar" > A { 'B' } </ option >
358+ </ select > ,
359+ 0 ,
360+ ) ;
361+ const option = e . options [ 0 ] ;
362+ if (
363+ render === serverRender ||
364+ render === streamRender ||
365+ render === clientRenderOnServerString
366+ ) {
367+ // We have three nodes because there is a comment between them.
368+ expect ( option . childNodes . length ) . toBe ( 3 ) ;
369+ expectNode ( option . childNodes [ 0 ] , TEXT_NODE_TYPE , 'A' ) ;
370+ expectNode ( option . childNodes [ 2 ] , TEXT_NODE_TYPE , 'B' ) ;
371+ } else {
372+ expect ( option . childNodes . length ) . toBe ( 1 ) ;
373+ expectNode ( option . childNodes [ 0 ] , TEXT_NODE_TYPE , 'A B' ) ;
374+ }
375+ } ) ;
376+ } ) ;
377+
344378 describe ( 'user interaction' , function ( ) {
345379 let ControlledInput ,
346380 ControlledTextArea ,
0 commit comments