poetic / reacterminator

Convert html to react components in es6 syntax.
56 stars 6 forks source link

Redux code not generated when inside a sub-component #13

Open dvmorris opened 8 years ago

dvmorris commented 8 years ago

This may be the expected behavior, but it has caused me to spin my wheels quite a bit today, so I thought I would bring it to your attention:

https://github.com/dvmorris/reacterminator/commit/8fab21f9df9127003e412cfeecacdad66b51afdd

This test demonstrates the issue, and fails with the following output:

  1) redux-integration should hook redux into a sub-component and generate redux files:

      AssertionError: expected '/* eslint-disable */\nimport React from \'react\';\n\nclass ReduxExampleEmailForm extends React.Component {\n  render() {\n    return (\n      <div>\n        <form id="email-form" name="email-form">\n          <input id="name" name="name" />\n          <button id="single-button">\n          </button>\n        </form>\n      </div>\n      );\n  }\n}\n;\n\nexport default ReduxExampleEmailForm;\n' to deeply equal '/* eslint-disable */\nimport React from \'react\';\nimport { connect as reduxConnect } from \'react-redux\';\nimport action from \'../action-creators/index\';\n\nclass ReduxExampleEmailForm extends React.Component {\n  render() {\n    return (\n      <div>\n        <form id="email-form" name="email-form" onSubmit={this.props[\'action.reduxExampleEmailForm.submitEmailForm\']}>\n          <input id="name"\n            name="name"\n            value={this.props[\'state.reduxExampleEmailForm.name\']}\n            onChange={this.props[\'action.reduxExampleEmailForm.changeName\']} />\n          <button id="single-button" onClick={this.props[\'action.reduxExampleEmailForm.clickSingleButton\']}>\n          </button>\n        </form>\n      </div>\n      );\n  }\n}\n;\nconst ReduxExampleEmailFormWithRedux = reduxConnect(\n  (state) => ({\n    \'state.reduxExampleEmailForm.name\': state.reduxExampleEmailForm.name,\n  }),\n  {\n    \'action.reduxExampleEmailForm.submitEmailForm\': action.reduxExampleEmailForm.submitEmailForm,\n    \'action.reduxExampleEmailForm.changeName\': action.reduxExampleEmailForm.changeName,\n    \'action.reduxExampleEmailForm.clickSingleButton\': action.reduxExampleEmailForm.clickSingleButton\n  }\n)(ReduxExampleEmailForm);\n\nexport default ReduxExampleEmailFormWithRedux;\n'
      + expected - actual

       /* eslint-disable */
       import React from 'react';
      +import { connect as reduxConnect } from 'react-redux';
      +import action from '../action-creators/index';

       class ReduxExampleEmailForm extends React.Component {
         render() {
           return (
             <div>
      -        <form id="email-form" name="email-form">
      -          <input id="name" name="name" />
      -          <button id="single-button">
      +        <form id="email-form" name="email-form" onSubmit={this.props['action.reduxExampleEmailForm.submitEmailForm']}>
      +          <input id="name"
      +            name="name"
      +            value={this.props['state.reduxExampleEmailForm.name']}
      +            onChange={this.props['action.reduxExampleEmailForm.changeName']} />
      +          <button id="single-button" onClick={this.props['action.reduxExampleEmailForm.clickSingleButton']}>
                 </button>
               </form>
             </div>
             );
         }
       }
       ;
      +const ReduxExampleEmailFormWithRedux = reduxConnect(
      +  (state) => ({
      +    'state.reduxExampleEmailForm.name': state.reduxExampleEmailForm.name,
      +  }),
      +  {
      +    'action.reduxExampleEmailForm.submitEmailForm': action.reduxExampleEmailForm.submitEmailForm,
      +    'action.reduxExampleEmailForm.changeName': action.reduxExampleEmailForm.changeName,
      +    'action.reduxExampleEmailForm.clickSingleButton': action.reduxExampleEmailForm.clickSingleButton
      +  }
      +)(ReduxExampleEmailForm);

      -export default ReduxExampleEmailForm;
      +export default ReduxExampleEmailFormWithRedux;

      at Function.assert.deepEqual (node_modules/chai/lib/chai/interface/assert.js:216:32)
      at Context.<anonymous> (test/integration/redux-integration.js:294:12)