i was wondering if someone has an idea on how to test a method that calls an UI plugin like share from facebook.
For example i have this code:
class Component extends Component{
facebookShare(actionId) {
const that = this;
window.FB.ui({
method: 'share',
quote: 'quote',
hashtag: "#hashtag",
mobile_iframe: true,
href: 'url.com',
}, function (response) {
if (response && !response.error_message) {
that.props.setComplete(actionId);
console.log('Posting completed.');
} else {
console.log('Error while posting.');
}
})
}
render(){
return <ComponentThatCallsFacebookShare/>
}
}
The problem is that if i execute the test there is no way to reach the window.FB variable that creates only after the facebook autologin execute its. Maybe there is a special way to test this kind of function? I tried to override it but the override does not cover all the statements (See Img) of the function and of course i cant just execute it. =/
Hope someone have the answer ;) thanks

Aucun commentaire:
Enregistrer un commentaire