Skip to content

Instantly share code, notes, and snippets.

@ihorkatkov
Last active September 19, 2018 09:04
Show Gist options
  • Save ihorkatkov/e8ff9e29e8ac64ef9ad1e4c28d64f8f2 to your computer and use it in GitHub Desktop.
Save ihorkatkov/e8ff9e29e8ac64ef9ad1e4c28d64f8f2 to your computer and use it in GitHub Desktop.
Story example
import React from 'react'
import { storiesOf, action } from '@storybook/react'
import Component from '../../../src/components/MunicipalitySelect/index'
import Provider from '../../../src/test/MockedApolloProvider'
const defaultValue = {
id: 'TG9jYXRpb246MzA=',
name: 'Vestby',
slug: 'vestby_akershus_municipality',
__typename: 'Location',
}
const resolvers = {
RootQueryType: {
locationsByParentId: () => [
{
slug: 'akershus_county',
name: 'Akershus',
id: 'TG9jYXRpb246Mjk=',
children: [
{
slug: 'vestby_akershus_municipality',
name: 'Vestby',
id: 'TG9jYXRpb246MzA=',
__typename: 'Location',
},
],
__typename: 'Location',
},
{
slug: 'oslo_county',
name: 'Oslo',
id: 'TG9jYXRpb246NTI=',
children: [
{
slug: 'oslo_oslo_municipality',
name: 'Oslo',
id: 'TG9jYXRpb246NTM=',
__typename: 'Location',
},
],
__typename: 'Location',
},
],
},
}
storiesOf('MunicipalitySelect', module)
.addDecorator(story => <Provider story={story()} resolvers={resolvers} />)
.add('default', () => <Component onChange={action('onChange')} />)
.add('with default value', () => (
<Component onChange={action('onChange')} defaultValue={defaultValue} />
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment