-
Notifications
You must be signed in to change notification settings - Fork 60
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
Understanding testStateMachine #72
Comments
Thank you very much for opening this issue, and for the kind words, @hally9k. Unless I'm missing something, For example: test('props work', () => {
const myStatechart = {
initial: 'myState',
states: { myState: {} },
}
const MyComponent = props => <div>{props.myProp}</div>
const StateMachine = withStateMachine(myStatechart)(MyComponent)
const initialData = { myProp: 'Hello, Props!' }
testStateMachine(StateMachine, { fixtures: { initialData } })
}) Generates the following snapshot: exports[`props work: myState 1`] = `
<div>
Hello, Props!
</div>
`; Please let me know if this answers your question, and any contribution to the README is more than welcome. |
@MicheleBertoli - I think this one might want to stay open. I appear to be able to reproduce when I pass nested objects as props. This is an example that fails: it('props work', () => {
const myStatechart = {
initial: 'myState',
states: { myState: {} }
}
const MyComponent = (props) => <div>{props.node.content.text}</div>
const StateMachine = withStateMachine(myStatechart)(MyComponent)
const initialData = { node: { content: { text: 'woot' } } }
testStateMachine(StateMachine, { fixtures: { initialData } })
})
|
Aha, good catch - Fixed in |
Firstly - Awesome work here man!! ❤️❤️❤️
Secondly - I am trying to understand
testStateMachine
from reading the README and I'll admit I'm slightly stumped. So I thought I'd reach out for some help and then maybe I can return the favour by fleshing out the README to be more friendly to slow people, like myself.The main thing I'm having trouble with is how to pass props into the component. After reading the README I thought that the
initialData
object in the fixtures would be passed into the component as props, but this doesn't seem to work. Am I missing something?The text was updated successfully, but these errors were encountered: