Created
January 31, 2019 05:28
-
-
Save Ranguro/bf1f2e95201fcd9cff32e2de86b13705 to your computer and use it in GitHub Desktop.
This is the scenario that reproduces an issue found where .findWhere returns empty wrappers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mount } from 'enzyme'; | |
import React from 'react'; | |
import EditableText from './../../../../../client/js/components/common/EditableText'; | |
describe('Search Page Component', () => { | |
const wrapper = mount( | |
<div className='somediv'> | |
<EditableText textValue=""> | |
<h1 id="TextLabel" title="" /> | |
</EditableText > | |
<EditableText textValue=""> | |
<h1 id="TextLabel" title="" /> | |
</EditableText> | |
</div> | |
); | |
wrapper.findWhere((item) => { | |
if (item.length === 0) { | |
console.log('An empty wrapper passed in .findWhere()'); | |
console.log(item.debug()); | |
} | |
}); | |
// Here add some expect method to avoid failure of the test. | |
} | |
); | |
// External Component (EditableText) | |
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
class EditableText extends Component { | |
constructor(props) { | |
super(props); | |
this.getEditableContent = this.getEditableContent.bind(this); | |
} | |
getEditableContent() { | |
return <h1 id="TextLabel" title={this.props.textValue}>{this.props.textValue}</h1>; | |
} | |
render() { | |
return ( | |
<div> | |
{this.getEditableContent()} | |
</div> | |
); | |
} | |
} | |
EditableText.propTypes = { | |
textValue: PropTypes.string.isRequired, | |
onSave: PropTypes.func | |
}; | |
export default EditableText; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment