Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: statechart is not defined when testing #79

Closed
joshpitzalis opened this issue Oct 15, 2018 · 3 comments
Closed

ReferenceError: statechart is not defined when testing #79

joshpitzalis opened this issue Oct 15, 2018 · 3 comments

Comments

@joshpitzalis
Copy link

I made a super simple component, no routing or redux confusion and then a test like it says in the docs and it says " ReferenceError: statechart is not defined" in the test runner console. I'm using jest. Am I doing something wrong?

@joshpitzalis
Copy link
Author

import PropTypes from 'prop-types';
import { withStateMachine } from 'react-automata';

export const stateMachine = {
  initial: 'idle',
  states: {
    idle: {
      on: {
        GIFT: 'loading'
      }
    },
    loading: {
      onEntry: 'checkReceiverDetails',
      on: {
        SUCCEED: 'confirm',
        ERROR: 'error'
      }
    },
    confirm: {
      on: {
        TRANSFER: 'transferring'
      }
    },
    transferring: {
      onEntry: 'transferOwnership',
      on: {
        SUCCEED: 'done',
        ERROR: 'error'
      }
    },
    done: {
      onEntry: 'redirectToMarket'
    },
    error: {
      on: {
        GIFT: 'loading'
      }
    }
  }
};

class Giftgems extends PureComponent {
  static propTypes = {};

  render() {
    return (
      <div>
        <p>hello</p>
      </div>
    );
  }
}

export default withStateMachine(statechart)(Giftgems);

and then for the test file...

import { testStateMachine } from 'react-automata';
import GiftGems from '../components/GiftGems';

test('GiftGems works', () => {
  testStateMachine(GiftGems);
});

@davidkpiano
Copy link
Contributor

You have it named stateMachine and not statechart in the provided code example.

@joshpitzalis
Copy link
Author

🤦‍♂️

Thank you David.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants