mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #4058 from yiminghe/className_contains
fix className check in scryRenderedDOMComponentsWithClass when encounter new line
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user