Merge pull request #2480 from spicyj/text-stability

Test that text spans aren't remounted needlessly
This commit is contained in:
Paul O’Shannessy
2014-11-07 16:56:58 -08:00
+18 -2
View File
@@ -18,12 +18,28 @@ describe('ReactTextComponent', function() {
React = require('React');
});
it('should escape the rootID', function(){
it('should escape the rootID', function() {
var ThisThingShouldBeEscaped = '">>> LULZ <<<"';
var ThisThingWasBeEscaped = '&quot;&gt;&gt;&gt; LULZ &lt;&lt;&lt;&quot;';
var thing = <div><span key={ThisThingShouldBeEscaped}>LULZ</span></div>;
var html = React.renderToString(thing);
expect(html).not.toContain(ThisThingShouldBeEscaped);
expect(html).toContain(ThisThingWasBeEscaped);
})
});
it('updates a mounted text component in place', function() {
var el = document.createElement('div');
var inst = React.render(<div>{'foo'}{'bar'}</div>, el);
var foo = inst.getDOMNode().children[0];
var bar = inst.getDOMNode().children[1];
expect(foo.tagName).toBe('SPAN');
expect(bar.tagName).toBe('SPAN');
var inst = React.render(<div>{'baz'}{'qux'}</div>, el);
// After the update, the spans should have stayed in place (as opposed to
// getting unmounted and remounted)
expect(inst.getDOMNode().children[0]).toBe(foo);
expect(inst.getDOMNode().children[1]).toBe(bar);
});
});