{"action":"created","issue":{"url":"https://api.github.com/repos/craigbilner/react-component-tester/issues/60","labels_url":"https://api.github.com/repos/craigbilner/react-component-tester/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/craigbilner/react-component-tester/issues/60/comments","events_url":"https://api.github.com/repos/craigbilner/react-component-tester/issues/60/events","html_url":"https://github.com/craigbilner/react-component-tester/issues/60","id":129448189,"number":60,"title":"tests using propFunc() and mapTo() fail because the invoked mapped callback does not receive the real event argument","user":{"login":"Fofir","id":1683589,"avatar_url":"https://avatars.githubusercontent.com/u/1683589?v=3","gravatar_id":"","url":"https://api.github.com/users/Fofir","html_url":"https://github.com/Fofir","followers_url":"https://api.github.com/users/Fofir/followers","following_url":"https://api.github.com/users/Fofir/following{/other_user}","gists_url":"https://api.github.com/users/Fofir/gists{/gist_id}","starred_url":"https://api.github.com/users/Fofir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fofir/subscriptions","organizations_url":"https://api.github.com/users/Fofir/orgs","repos_url":"https://api.github.com/users/Fofir/repos","events_url":"https://api.github.com/users/Fofir/events{/privacy}","received_events_url":"https://api.github.com/users/Fofir/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/craigbilner/react-component-tester/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/craigbilner/react-component-tester/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-28T13:08:35Z","updated_at":"2016-02-02T09:36:50Z","closed_at":null,"body":"Let's say i have the following component class:\r\n\r\n```\r\nclass MyComponent extends Component\r\n{\r\n\r\n\r\n    onChange( evt )\r\n    {\r\n        const { name, value } = evt.target;\r\n        console.log( name, value );\r\n    }\r\n\r\n\r\n    render ()\r\n    {\r\n        return ( <input name=\"username\" onChange={this.onChange} />)\r\n    }\r\n\r\n}\r\n```\r\n\r\nand the following test:\r\n```\r\nit( 'fires onChange', () =>\r\n{\r\n    const inputs = MY_COMPONENT.findComponents( 'input' );\r\n    const isMapped = inputs[0].propFunc( 'onChange' ).mapsTo( 'onChange' );\r\n    expect( isMapped ).toBe( true );\r\n} );\r\n```\r\n\r\nThis will fail because `evt.target` is undefined. \r\n\r\nFrom what i checked,  the `onInputChange` invoked  by the `propFunc/mapsTo` combination gets a different argument that the actual event, which is `Symbol(onChange)`.\r\n\r\nMy question is why is it so?"},"comment":{"url":"https://api.github.com/repos/craigbilner/react-component-tester/issues/comments/178475563","html_url":"https://github.com/craigbilner/react-component-tester/issues/60#issuecomment-178475563","issue_url":"https://api.github.com/repos/craigbilner/react-component-tester/issues/60","id":178475563,"user":{"login":"Fofir","id":1683589,"avatar_url":"https://avatars.githubusercontent.com/u/1683589?v=3","gravatar_id":"","url":"https://api.github.com/users/Fofir","html_url":"https://github.com/Fofir","followers_url":"https://api.github.com/users/Fofir/followers","following_url":"https://api.github.com/users/Fofir/following{/other_user}","gists_url":"https://api.github.com/users/Fofir/gists{/gist_id}","starred_url":"https://api.github.com/users/Fofir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fofir/subscriptions","organizations_url":"https://api.github.com/users/Fofir/orgs","repos_url":"https://api.github.com/users/Fofir/repos","events_url":"https://api.github.com/users/Fofir/events{/privacy}","received_events_url":"https://api.github.com/users/Fofir/received_events","type":"User","site_admin":false},"created_at":"2016-02-02T09:36:50Z","updated_at":"2016-02-02T09:36:50Z","body":"Hi @craigbilner !\r\n\r\nThanks for the help. I will try and use `withArgs` and hopefully this solves my case.\r\n\r\nI was thinking about using sinon stubs but couldn't figure it out yet. As you mentioned:\r\n\r\n> It can't stub the method instead either because at this point it's too late and some methods that effect render need to be called rather than stubbed out which is hard to infer."}}