Merge pull request #4058 from yiminghe/className_contains

fix className check in scryRenderedDOMComponentsWithClass when encounter new line
This commit is contained in:
Paul O’Shannessy
2015-06-11 09:37:09 -07:00
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ var ReactTestUtils = {
var instClassName = React.findDOMNode(inst).className;
return (
instClassName &&
(' ' + instClassName + ' ').indexOf(' ' + className + ' ') !== -1
(('' + instClassName).split(/\s+/)).indexOf(className) !== -1
);
}
return false;
+11
View File
@@ -187,6 +187,17 @@ describe('ReactTestUtils', function() {
});
it('Test scryRenderedDOMComponentsWithClass with className contains \\n', function() {
var renderedComponent = ReactTestUtils.renderIntoDocument(
<div>Hello <span className={'x\ny'}>Jim</span></div>
);
var scryResults = ReactTestUtils.scryRenderedDOMComponentsWithClass(
renderedComponent,
'x'
);
expect(scryResults.length).toBe(1);
});
it('traverses children in the correct order', function() {
var container = document.createElement('div');