diff --git a/src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js b/src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js index bdb8e4020c166..70a37d39bf159 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js @@ -13,11 +13,13 @@ var React; var ReactDOM; +var ReactDOMServer; describe('ReactDOMTextComponent', function() { beforeEach(function() { React = require('React'); ReactDOM = require('ReactDOM'); + ReactDOMServer = require('ReactDOMServer'); }); it('updates a mounted text component in place', function() { @@ -90,4 +92,26 @@ describe('ReactDOMTextComponent', function() { inst = ReactDOM.render(
{'bar'}
, el); expect(textNode.data).toBe('bar'); }); + + it('are preserved in pre-rendered markup', function() { + var el = document.createElement('div'); + var reactElements =
{'foo'}{'bar'}{'baz'}
; + el.innerHTML = ReactDOMServer.renderToString(reactElements); + + var childNodes = el.childNodes[0].childNodes; + var text1 = childNodes[0]; + var span1 = childNodes[1]; + var text2 = childNodes[2]; + var span2 = childNodes[3]; + var text3 = childNodes[4]; + + var inst = ReactDOM.render(reactElements, el); + childNodes = ReactDOM.findDOMNode(inst).childNodes; + expect(childNodes.length).toBe(5); + expect(childNodes[0]).toBe(text1); + expect(childNodes[1]).toBe(span1); + expect(childNodes[2]).toBe(text2); + expect(childNodes[3]).toBe(span2); + expect(childNodes[4]).toBe(text3); + }); });