From a43ba2625b8ba170b4e30ce7c4e5cf1975ff5b88 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 2 Aug 2017 01:05:42 +0100 Subject: [PATCH] Add an extra test for arrays and strings from composites (#10346) --- .../ReactDOMServerIntegration-test.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js index 8654506b56282..d6fba2a876765 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js @@ -1391,6 +1391,34 @@ describe('ReactDOMServerIntegration', () => { expectTextNode(textNode2, ' '); }, ); + + if (ReactDOMFeatureFlags.useFiber) { + itRenders('a composite with multiple children', async render => { + const Component = props => props.children; + const e = await render( + {['a', 'b', [undefined], [[false, 'c']]]}, + ); + + let parent = e.parentNode; + if ( + render === serverRender || + render === clientRenderOnServerString || + render === streamRender + ) { + // For plain server markup result we have comments between. + // If we're able to hydrate, they remain. + expect(parent.childNodes.length).toBe(5); + expectTextNode(parent.childNodes[0], 'a'); + expectTextNode(parent.childNodes[2], 'b'); + expectTextNode(parent.childNodes[4], 'c'); + } else { + expect(parent.childNodes.length).toBe(3); + expectTextNode(parent.childNodes[0], 'a'); + expectTextNode(parent.childNodes[1], 'b'); + expectTextNode(parent.childNodes[2], 'c'); + } + }); + } }); describe('escaping >, <, and &', function() {