Last active
March 28, 2019 10:38
-
-
Save faceyspacey/91f9faa2ff64a50c11be83be83830d21 to your computer and use it in GitHub Desktop.
Respond Framework support for Statecharts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { testGenerator } from 'respond-framework/test' | |
const routes = { | |
LOGIN: '/login', | |
SIGNUP: '/signup', | |
POST: '/post/:slug', | |
HOME: { | |
path: '/', | |
next: { | |
LOGIN: request => !!request.getState().cookies.existingUser, | |
SIGNUP: request => !request.getState().cookies.existingUser, | |
POST: { | |
cond: request => !!request.getState().loggedIn, | |
target: request => request.getState().posts.map(post => ({ | |
type: 'POST', | |
params: { slug: post.slug } | |
})), | |
fallback: 'LOGIN' | |
} | |
} | |
} | |
} | |
describe('generated tests', async () => { | |
const options = { | |
initialState: { | |
posts: [ | |
{ slug: '/respond-rocks' }, | |
{ slug: '/thunk-life' } | |
] | |
} | |
} | |
await testGenerator(routes, options) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment