{"action":"created","issue":{"url":"https://api.github.com/repos/airbnb/enzyme/issues/208","repository_url":"https://api.github.com/repos/airbnb/enzyme","labels_url":"https://api.github.com/repos/airbnb/enzyme/issues/208/labels{/name}","comments_url":"https://api.github.com/repos/airbnb/enzyme/issues/208/comments","events_url":"https://api.github.com/repos/airbnb/enzyme/issues/208/events","html_url":"https://github.com/airbnb/enzyme/issues/208","id":135503837,"number":208,"title":"Testing component methods","user":{"login":"mxstbr","id":7525670,"avatar_url":"https://avatars.githubusercontent.com/u/7525670?v=3","gravatar_id":"","url":"https://api.github.com/users/mxstbr","html_url":"https://github.com/mxstbr","followers_url":"https://api.github.com/users/mxstbr/followers","following_url":"https://api.github.com/users/mxstbr/following{/other_user}","gists_url":"https://api.github.com/users/mxstbr/gists{/gist_id}","starred_url":"https://api.github.com/users/mxstbr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxstbr/subscriptions","organizations_url":"https://api.github.com/users/mxstbr/orgs","repos_url":"https://api.github.com/users/mxstbr/repos","events_url":"https://api.github.com/users/mxstbr/events{/privacy}","received_events_url":"https://api.github.com/users/mxstbr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-02-22T18:39:08Z","updated_at":"2016-12-30T11:14:01Z","closed_at":"2016-02-22T19:16:30Z","body":"_I couldn't find any information on this, if this is a duplicate excuse me for stealing your time._\n\nI'm trying to test [this application](https://github.com/mxstbr/react-boilerplate/tree/v3.0.0), but I ran into a wall when testing component methods. As an example, take this component:\n\n``` JS\nclass Button extends React.Component {\n  handleClick() {\n    // Do something here\n  }\n  render() {\n    // Component here\n  }\n}\n```\n\nHow could I test the `handleClick` method here when shallowly rendering this component? (The same question applies to lifecycle methods)\n"},"comment":{"url":"https://api.github.com/repos/airbnb/enzyme/issues/comments/269760109","html_url":"https://github.com/airbnb/enzyme/issues/208#issuecomment-269760109","issue_url":"https://api.github.com/repos/airbnb/enzyme/issues/208","id":269760109,"user":{"login":"nikunjgami1991","id":22093506,"avatar_url":"https://avatars.githubusercontent.com/u/22093506?v=3","gravatar_id":"","url":"https://api.github.com/users/nikunjgami1991","html_url":"https://github.com/nikunjgami1991","followers_url":"https://api.github.com/users/nikunjgami1991/followers","following_url":"https://api.github.com/users/nikunjgami1991/following{/other_user}","gists_url":"https://api.github.com/users/nikunjgami1991/gists{/gist_id}","starred_url":"https://api.github.com/users/nikunjgami1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikunjgami1991/subscriptions","organizations_url":"https://api.github.com/users/nikunjgami1991/orgs","repos_url":"https://api.github.com/users/nikunjgami1991/repos","events_url":"https://api.github.com/users/nikunjgami1991/events{/privacy}","received_events_url":"https://api.github.com/users/nikunjgami1991/received_events","type":"User","site_admin":false},"created_at":"2016-12-30T11:14:01Z","updated_at":"2016-12-30T11:14:01Z","body":"Hi \r\n\r\nI have tried below solution for calling methods of component and it is working fine for components having state.\r\n\r\nBut, I have one stateless component and I want to test one method of that component ans I am getting below error.\r\n\r\n//Error \r\n`    TypeError: wrapper.instance(...).setFocusToTextBox is not a function\r\n\r\n      at Object.<anonymous> (src\\Engines\\LeadershipTrait\\__test__\\RatingInput.test.js:69:28)\r\n`\r\n\r\n// Stateless component method\r\n`    const setFocusToTextBox = (index) => {\r\n        window.setTimeout(function () {\r\n            let textbox = document.getElementById(\"rating\"+props.index+index);                    \r\n            textbox.focus();\r\n        },0);\r\n    }`\r\n\r\n// Testcase \r\n`    /**Checking setToFocus method*/\r\n    it('Checking setToFocus method', () => {\r\n        let enteredRating = [[1,0,0,0,0,0]];        \r\n        //render component for even number row with selectedRating\r\n        let wrapper = shallow(<RatingInput index={oddIndex} ratingEntered={enteredRating} rating={rating}/>);\r\n        wrapper.instance().setFocusToTextBox(1);        \r\n    });`\r\n\r\nPlease guide where i am doing mistake.\r\n\r\nThank you,\r\nNikunj."}}
{"actor":{"display_login":"nikunjgami1991"}}