deepakaggarwal7 / react-social-login

MIT License
372 stars 142 forks source link

Test with Jest failing #132

Open Kif11 opened 5 years ago

Kif11 commented 5 years ago

I'm trying to test one of my components with Jest that use SocialButton. Set up is exactly in provided example.

it('renders correctly', () => {
  const wrapper = shallow(<SocialButton />);
  console.log(wrapper.html());
});

I'm getting this error. Any ideas what can be wrong?

TypeError: Cannot read property 'render' of undefined

I think, this is happening because react-social-login/dist/social-login.js in NPM distribution is minified.

Kif11 commented 5 years ago

Hmm, I build the project without webpack Uglify plugging. It is failing on the last line of this snippet:

/**
 * React Higher Order Component handling social login for multiple providers.
 * @param {Element} WrappedComponent
 * @constructor
 */
var SocialLogin = function SocialLogin(WrappedComponent) {
  var _class, _temp;

  return _temp = _class = function (_Component) {
    _inherits(SocialLogin, _Component);

    function SocialLogin(props) {
      _classCallCheck(this, SocialLogin);

      var _this = _possibleConstructorReturn(this, (SocialLogin.__proto__ || Object.getPrototypeOf(SocialLogin)).call(this, props));

      _this.isStateless = !WrappedComponent.prototype.render;
Kif11 commented 5 years ago

@deepakaggarwal7 any ideas?

deepakaggarwal7 commented 3 years ago

There are a few issues mentioning that the component doesn't work as functional component as prototype isn't supported. Will check more.