Guest User

Untitled

a guest
Nov 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. class ComponentToBeTested extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. isActive: false
  6. };
  7. this.handleButtonClick = this.handleButtonClick.bind(this);
  8. }
  9.  
  10. handleButtonClick() {
  11. this.setState({
  12. isActive: !this.state.isActive
  13. });
  14. }
  15.  
  16. multiply(data) {
  17. return data * 10;
  18. }
  19.  
  20. square(data) {
  21. return Math.pow(data, 2);
  22. }
  23.  
  24. render() {
  25. const givenData = this.props.data;
  26. const multipliedData = this.multiply(givenData);
  27. const squaredData = this.square(givenData);
  28.  
  29. return (
  30. <div className="ComponentToBeTested">
  31. <button className="test-button" onClick={this.handleButtonClick}>
  32. FOO
  33. </button>
  34. <ChildComponent data={multipliedData} />
  35. <span className="squared-data">{squaredData}</span>
  36. </div>
  37. );
  38. }
Add Comment
Please, Sign In to add comment